--- 2908886-40.patch 2020-05-13 18:53:25.952241483 +0300 +++ 2908886-9.1-46.patch 2020-05-13 19:36:01.044218014 +0300 @@ -1,60 +1,61 @@ diff --git a/core/core.services.yml b/core/core.services.yml -index 1cddf59cfe..80ab725b00 100644 +index c42ca2dd21..ce14474f8f 100644 --- a/core/core.services.yml +++ b/core/core.services.yml -@@ -515,7 +515,7 @@ services: +@@ -522,7 +522,7 @@ services: class: Drupal\Core\Extension\ModuleInstaller tags: - { name: service_collector, tag: 'module_install.uninstall_validator', call: addUninstallValidator } -- arguments: ['@app.root', '@module_handler', '@kernel'] +- arguments: ['%app.root%', '@module_handler', '@kernel'] + arguments: ['@app.root', '@module_handler', '@kernel', '@schema_installer'] lazy: true extension.list.module: class: Drupal\Core\Extension\ModuleExtensionList -@@ -547,6 +547,10 @@ services: +@@ -560,6 +560,10 @@ services: theme_installer: class: Drupal\Core\Extension\ThemeInstaller - arguments: ['@theme_handler', '@config.factory', '@config.installer', '@module_handler', '@config.manager', '@asset.css.collection_optimizer', '@router.builder', '@logger.channel.default', '@state'] + arguments: ['@theme_handler', '@config.factory', '@config.installer', '@module_handler', '@config.manager', '@asset.css.collection_optimizer', '@router.builder', '@logger.channel.default', '@state', '@extension.list.module'] + schema_installer: + class: Drupal\Core\Extension\SchemaInstaller + arguments: ['@module_handler', '@cache.default', '@keyvalue', '@database', '@cache_tags.invalidator'] + lazy: true - # @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Use the other - # entity* services instead. - entity.manager: + entity.memory_cache: + class: Drupal\Core\Cache\MemoryCache\MemoryCache + entity_type.manager: diff --git a/core/includes/install.inc b/core/includes/install.inc -index 2834e918f5..2e1baa6017 100644 +index e806a09a41..e11a7c480e 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -80,7 +80,9 @@ - * Loads .install files for installed modules to initialize the update system. - */ function drupal_load_updates() { + /** @var \Drupal\Core\Extension\ModuleExtensionList $extension_list_module */ + $extension_list_module = \Drupal::service('extension.list.module'); - foreach (drupal_get_installed_schema_version(NULL, FALSE, TRUE) as $module => $schema_version) { + /** @var \Drupal\Core\Extension\SchemaInstallerInterface $schema_installer */ + $schema_installer = \Drupal::service('schema_installer'); + foreach ($schema_installer->getInstalledVersions() as $module => $schema_version) { - if ($schema_version > -1) { - module_load_install($module); - } + if ($extension_list_module->exists($module) && !$extension_list_module->checkIncompatibility($module)) { + if ($schema_version > -1) { + module_load_install($module); diff --git a/core/includes/schema.inc b/core/includes/schema.inc -index 0129d19334..05c68b7cc5 100644 +index e168e89556..bd0a5602d7 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc -@@ -6,6 +6,7 @@ +@@ -5,6 +5,8 @@ + * Schema API handling functions. */ - use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema; +use Drupal\Core\Extension\SchemaInstallerInterface; - ++ /** * @addtogroup schemaapi -@@ -14,8 +15,13 @@ + * @{ +@@ -12,8 +14,13 @@ /** * Indicates that a module has not been installed yet. + * -+ * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. ++ * @deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. + * Use \Drupal\Core\Extension\SchemaInstallerInterface::UNINSTALLED. + * + * @see https://www.drupal.org/node/2970993 @@ -64,7 +65,7 @@ /** * Returns an array of available schema versions for a module. -@@ -72,28 +78,26 @@ function drupal_get_schema_versions($module) { +@@ -70,27 +77,24 @@ function drupal_get_schema_versions($module) { * system. * * @return string|int @@ -73,7 +74,7 @@ + * The currently installed schema version, or + * SchemaInstallerInterface::UNINSTALLED if the module is not installed. + * -+ * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use ++ * @deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. Use + * SchemaInstallerInterface::getInstalledVersion() instead. + * + * @see https://www.drupal.org/node/2970993 @@ -82,19 +83,19 @@ function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) { - $versions = &drupal_static(__FUNCTION__, []); - -+ @trigger_error('drupal_get_installed_schema_version() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::getInstalledVersion() instead. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED); ++ @trigger_error('drupal_get_installed_schema_version() is deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::getInstalledVersion() instead. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED); + /** @var \Drupal\Core\Extension\SchemaInstallerInterface $schema_installer */ + $schema_installer = \Drupal::service('schema_installer'); if ($reset) { - $versions = []; -- } ++ $schema_installer->resetCache(); + } - - if (!$versions) { - if (!$versions = \Drupal::keyValue('system.schema')->getAll()) { - $versions = []; - } -+ $schema_installer->resetCache(); - } +- } - if ($array) { - return $versions; @@ -103,16 +104,14 @@ - return isset($versions[$module]) ? $versions[$module] : SCHEMA_UNINSTALLED; + return $schema_installer->getInstalledVersions(); } -+ return $schema_installer->getInstalledVersion($module); } - /** -@@ -103,11 +107,16 @@ function drupal_get_installed_schema_version($module, $reset = FALSE, $array = F +@@ -101,11 +105,16 @@ function drupal_get_installed_schema_version($module, $reset = FALSE, $array = F * A module name. * @param string $version * The new schema version. + * -+ * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use ++ * @deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. Use + * SchemaInstallerInterface::setInstalledVersion() instead. + * + * @see https://www.drupal.org/node/2970993 @@ -122,17 +121,17 @@ - \Drupal::keyValue('system.schema')->set($module, $version); - // Reset the static cache of module schema versions. - drupal_get_installed_schema_version(NULL, TRUE); -+ @trigger_error('drupal_set_installed_schema_version() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::setInstalledVersion() instead. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED); ++ @trigger_error('drupal_set_installed_schema_version() is deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::setInstalledVersion() instead. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED); + \Drupal::service('schema_installer')->setInstalledVersion($module, $version); } /** -@@ -115,14 +124,16 @@ function drupal_set_installed_schema_version($module, $version) { +@@ -113,14 +122,16 @@ function drupal_set_installed_schema_version($module, $version) { * * @param string $module * The module for which the tables will be created. + * -+ * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use ++ * @deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. Use + * SchemaInstallerInterface::install() instead. + * + * @see https://www.drupal.org/node/2970993 @@ -145,17 +144,17 @@ - foreach ($schema as $name => $table) { - \Drupal::database()->schema()->createTable($name, $table); - } -+ @trigger_error('drupal_install_schema() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::install() instead. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED); ++ @trigger_error('drupal_install_schema() is deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::install() instead. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED); + \Drupal::service('schema_installer')->install($module); } /** -@@ -130,16 +141,16 @@ function drupal_install_schema($module) { +@@ -128,16 +139,16 @@ function drupal_install_schema($module) { * * @param string $module * The module for which the tables will be removed. + * -+ * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use ++ * @deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. Use + * SchemaInstallerInterface::uninstall() instead. + * + * @see https://www.drupal.org/node/2970993 @@ -170,17 +169,17 @@ - $schema->dropTable($table['name']); - } - } -+ @trigger_error('drupal_uninstall_schema() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::uninstall() instead. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED); ++ @trigger_error('drupal_uninstall_schema() is deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::uninstall() instead. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED); + \Drupal::service('schema_installer')->uninstall($module); } /** -@@ -154,22 +165,16 @@ function drupal_uninstall_schema($module) { +@@ -152,22 +163,16 @@ function drupal_uninstall_schema($module) { * @param string $table * The name of the table. If not given, the module's complete schema * is returned. + * -+ * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use ++ * @deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. Use + * SchemaInstallerInterface::getSchema() instead. + * + * @see https://www.drupal.org/node/2970993 @@ -201,17 +200,17 @@ - return $schema; - } - return []; -+ @trigger_error('drupal_get_module_schema() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::uninstall() instead. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED); ++ @trigger_error('drupal_get_module_schema() is deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::uninstall() instead. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED); + return \Drupal::service('schema_installer')->getSchema($module, $table); } /** -@@ -184,8 +189,14 @@ function drupal_get_module_schema($module, $table = NULL) { +@@ -182,8 +187,14 @@ function drupal_get_module_schema($module, $table = NULL) { * (optional) Whether to additionally remove 'description' keys of all tables * and fields to improve performance of serialize() and unserialize(). * Defaults to TRUE. + * -+ * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. No ++ * @deprecated in drupal:9.0.0 and is removed from drupal:9.1.0. No + * direct replacement provided. + * + * @see https://www.drupal.org/node/2970993 @@ -222,7 +221,7 @@ foreach ($schema as $name => &$table) { if (empty($table['module'])) { diff --git a/core/includes/update.inc b/core/includes/update.inc -index 792e94c286..e1f0ec2426 100644 +index 123ad46830..532b0b89bf 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -9,6 +9,7 @@ @@ -230,10 +229,10 @@ use Drupal\Component\Graph\Graph; +use Drupal\Core\Extension\SchemaInstallerInterface; - use Drupal\Core\Update\UpdateKernel; use Drupal\Core\Utility\Error; -@@ -74,7 +75,7 @@ function update_check_incompatibility($name, $type = 'module') { + /** +@@ -49,7 +50,7 @@ function update_check_incompatibility($name, $type = 'module') { function update_system_schema_requirements() { $requirements = []; @@ -242,7 +241,7 @@ $requirements['minimum schema']['title'] = 'Minimum schema version'; if ($system_schema >= \Drupal::CORE_MINIMUM_SCHEMA_VERSION) { -@@ -115,12 +116,11 @@ function update_check_requirements() { +@@ -147,12 +148,11 @@ function _update_fix_missing_schema() { * The schema version the module should be set to. */ function update_set_schema($module, $schema_version) { @@ -256,7 +255,7 @@ } /** -@@ -216,7 +216,7 @@ function update_do_one($module, $number, $dependency_map, &$context) { +@@ -248,7 +248,7 @@ function update_do_one($module, $number, $dependency_map, &$context) { // Record the schema update if it was completed successfully. if ($context['finished'] == 1 && empty($ret['#abort'])) { @@ -265,20 +264,22 @@ } $context['message'] = t('Updating @module', ['@module' => $module]); -@@ -305,10 +305,10 @@ function update_get_update_list() { +@@ -337,12 +337,12 @@ function update_get_update_list() { // Make sure that the system module is first in the list of updates. $ret = ['system' => []]; - $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE); + $modules = \Drupal::service('schema_installer')->getInstalledVersions(); + /** @var \Drupal\Core\Extension\ExtensionList $extension_list */ + $extension_list = \Drupal::service('extension.list.module'); foreach ($modules as $module => $schema_version) { // Skip uninstalled and incompatible modules. -- if ($schema_version == SCHEMA_UNINSTALLED || update_check_incompatibility($module)) { +- if ($schema_version == SCHEMA_UNINSTALLED || $extension_list->checkIncompatibility($module)) { + if ($schema_version == SchemaInstallerInterface::UNINSTALLED || update_check_incompatibility($module)) { continue; } // Display a requirements error if the user somehow has a schema version -@@ -585,7 +585,7 @@ function update_is_missing($module, $number, $update_functions) { +@@ -611,7 +611,7 @@ function update_is_missing($module, $number, $update_functions) { * performed; FALSE otherwise. */ function update_already_performed($module, $number) { @@ -287,7 +288,7 @@ } /** -@@ -608,7 +608,7 @@ function update_retrieve_dependencies() { +@@ -634,7 +634,7 @@ function update_retrieve_dependencies() { // Get a list of installed modules, arranged so that we invoke their hooks in // the same order that \Drupal::moduleHandler()->invokeAll() does. foreach (\Drupal::keyValue('system.schema')->getAll() as $module => $schema) { @@ -297,7 +298,7 @@ continue; } diff --git a/core/lib/Drupal/Core/Database/database.api.php b/core/lib/Drupal/Core/Database/database.api.php -index 82b6408669..7d8c14dada 100644 +index a7ccdc32a0..44898b9fe9 100644 --- a/core/lib/Drupal/Core/Database/database.api.php +++ b/core/lib/Drupal/Core/Database/database.api.php @@ -390,7 +390,7 @@ @@ -323,7 +324,7 @@ $extensions = $this->moduleHandler->buildModuleDependencies($extensions); diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php -index e0327fb769..6c32ff7fe0 100644 +index 09f8434370..306663f8b5 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -43,6 +43,13 @@ class ModuleInstaller implements ModuleInstallerInterface { @@ -372,16 +373,16 @@ // Clear plugin manager caches. \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions(); -@@ -286,7 +300,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { +@@ -293,7 +307,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { if ($last_removed = $this->moduleHandler->invoke($module, 'update_last_removed')) { $version = max($version, $last_removed); } - drupal_set_installed_schema_version($module, $version); + $this->schemaInstaller->setInstalledVersion($module, $version); - // Ensure that all post_update functions are registered already. - /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */ -@@ -451,7 +465,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { + // Ensure that all post_update functions are registered already. This + // should include existing post-updates, as well as any specified as +@@ -464,7 +478,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { } // Remove the schema. @@ -390,7 +391,7 @@ // Remove the module's entry from the config. Don't check schema when // uninstalling a module since we are only clearing a key. -@@ -501,7 +515,8 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { +@@ -514,7 +528,8 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // fastCGI which executes ::destruct() after the Module uninstallation page // was sent already. \Drupal::service('router.builder')->rebuild(); @@ -399,7 +400,7 @@ + $this->schemaInstaller->getInstalledVersions(); // Let other modules react. - $this->moduleHandler->invokeAll('modules_uninstalled', [$module_list]); + $this->moduleHandler->invokeAll('modules_uninstalled', [$module_list, $sync_status]); diff --git a/core/lib/Drupal/Core/Extension/SchemaInstaller.php b/core/lib/Drupal/Core/Extension/SchemaInstaller.php new file mode 100644 index 0000000000..742f4dbb09 @@ -869,117 +870,8 @@ + } + +} -diff --git a/core/modules/block/block.post_update.php b/core/modules/block/block.post_update.php -index e9e332ad08..8223391c85 100644 ---- a/core/modules/block/block.post_update.php -+++ b/core/modules/block/block.post_update.php -@@ -13,7 +13,7 @@ function block_post_update_disable_blocks_with_missing_contexts() { - // which used to do the same. Note: Its okay to check here, because - // update_do_one() does not update the installed schema version until the - // batch is finished. -- $module_schema = drupal_get_installed_schema_version('block'); -+ $module_schema = \Drupal::service('schema_installer')->getInstalledVersion('block'); - - // The state entry 'block_update_8002_placeholder' is used in order to - // indicate that the placeholder block_update_8002() function has been -diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install -index b02b432ecb..61e2c0b220 100644 ---- a/core/modules/comment/comment.install -+++ b/core/modules/comment/comment.install -@@ -15,8 +15,10 @@ - * Implements hook_requirements(). - */ - function comment_requirements($phase) { -+ /** @var \Drupal\Core\Extension\SchemaInstallerInterface $schema_installer */ -+ $schema_installer = \Drupal::service('schema_installer'); - $requirements = []; -- if ($phase === 'update' && drupal_get_installed_schema_version('comment') < 8701) { -+ if ($phase === 'update' && $schema_installer->getInstalledVersion('comment') < 8701) { - $has_empty_columns = \Drupal::entityQuery('comment', 'OR') - ->condition('entity_type', NULL, 'IS NULL') - ->condition('field_name', NULL, 'IS NULL') -diff --git a/core/modules/node/node.install b/core/modules/node/node.install -index e05c841128..a746bf286e 100644 ---- a/core/modules/node/node.install -+++ b/core/modules/node/node.install -@@ -252,7 +252,7 @@ function node_update_8301() { - * Fix realm column description on the node_access table. - */ - function node_update_8400() { -- $schema = drupal_get_module_schema('node', 'node_access'); -+ $schema = \Drupal::service('schema_installer')->getSchema('node', 'node_access'); - $schema['fields']['realm']['description'] = 'The realm in which the user must possess the grant ID. Modules can define one or more realms by implementing hook_node_grants().'; - Database::getConnection()->schema()->changeField('node_access', 'realm', 'realm', $schema['fields']['realm']); - } -diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php -index b212bc5961..20bca04d98 100644 ---- a/core/modules/simpletest/src/KernelTestBase.php -+++ b/core/modules/simpletest/src/KernelTestBase.php -@@ -462,8 +462,9 @@ protected function installSchema($module, $tables) { - } - - $tables = (array) $tables; -+ $schema_installer = \Drupal::service('schema_installer'); - foreach ($tables as $table) { -- $schema = drupal_get_module_schema($module, $table); -+ $schema = $schema_installer->getSchema($module, $table); - if (empty($schema)) { - // BC layer to avoid some contrib tests to fail. - // @todo Remove the BC layer before 8.1.x release. -diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php -index d34ff91e6e..a3fb38d475 100644 ---- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php -+++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php -@@ -127,7 +127,7 @@ public function testEnableModulesInstall() { - $this->assertTrue(in_array($module, $list), "{$module}_hook_info() in \Drupal::moduleHandler()->getImplementations() found."); - - $this->assertTrue(Database::getConnection()->schema()->tableExists($table), "'$table' database table found."); -- $schema = drupal_get_module_schema($module, $table); -+ $schema = \Drupal::service('schema_installer')->getSchema($module, $table); - $this->assertTrue($schema, "'$table' table schema found."); - } - -@@ -159,7 +159,9 @@ public function testInstallSchema() { - $this->assertTrue(Database::getConnection()->schema()->tableExists($table), "'$table' database table found."); - - // Verify that the schema is known to Schema API. -- $schema = drupal_get_module_schema($module, $table); -+ /** @var \Drupal\Core\Extension\SchemaInstaller $schema_installer */ -+ $schema_installer = \Drupal::service('schema_installer'); -+ $schema = $schema_installer->getSchema($module, $table); - $this->assertTrue($schema, "'$table' table schema found."); - - // Verify that a unknown table from an enabled module throws an error. -@@ -172,7 +174,7 @@ public function testInstallSchema() { - $this->pass('Exception for non-retrievable schema found.'); - } - $this->assertFalse(Database::getConnection()->schema()->tableExists($table), "'$table' database table not found."); -- $schema = drupal_get_module_schema($module, $table); -+ $schema = $schema_installer->getSchema($module, $table); - $this->assertFalse($schema, "'$table' table schema not found."); - - // Verify that a table from a unknown module cannot be installed. -@@ -186,14 +188,15 @@ public function testInstallSchema() { - $this->pass('Exception for non-retrievable schema found.'); - } - $this->assertFalse(Database::getConnection()->schema()->tableExists($table), "'$table' database table not found."); -- $schema = drupal_get_module_schema($module, $table); -- $this->assertTrue($schema, "'$table' table schema found."); -+ $schema = $schema_installer->getSchema($module, $table); -+ // Not installed module returns empty schema. -+ $this->assertTrue(empty($schema), "'$table' table schema empty."); - - // Verify that the same table can be installed after enabling the module. - $this->enableModules([$module]); - $this->installSchema($module, $table); - $this->assertTrue(Database::getConnection()->schema()->tableExists($table), "'$table' database table found."); -- $schema = drupal_get_module_schema($module, $table); -+ $schema = $schema_installer->getSchema($module, $table); - $this->assertTrue($schema, "'$table' table schema found."); - } - diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php -index 25a2a70891..082d55a323 100644 +index 2d1e88605f..d30a44721f 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -5,6 +5,7 @@ @@ -1034,7 +926,7 @@ ); } -@@ -599,7 +611,7 @@ protected function triggerBatch(Request $request) { +@@ -598,7 +610,7 @@ protected function triggerBatch(Request $request) { // correct place. (The updates are already sorted, so we can simply base // this on the first one we come across in the above foreach loop.) if (isset($start[$update['module']])) { @@ -1044,7 +936,7 @@ } $operations[] = ['update_do_one', [$update['module'], $update['number'], $dependency_map[$function]]]; diff --git a/core/modules/system/src/Form/ModulesUninstallForm.php b/core/modules/system/src/Form/ModulesUninstallForm.php -index 9370050d15..26c939a832 100644 +index 52f378e709..3a01edd998 100644 --- a/core/modules/system/src/Form/ModulesUninstallForm.php +++ b/core/modules/system/src/Form/ModulesUninstallForm.php @@ -8,6 +8,7 @@ @@ -1102,55 +994,14 @@ foreach (array_keys($module->required_by) as $dependent) { - if (drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) { + if ($this->schemaInstaller->getInstalledVersion($dependent) != SchemaInstallerInterface::UNINSTALLED) { - $name = isset($modules[$dependent]->info['name']) ? $modules[$dependent]->info['name'] : $dependent; - $form['modules'][$module->getName()]['#required_by'][] = $name; + $form['modules'][$module->getName()]['#required_by'][] = $dependent; $form['uninstall'][$module->getName()]['#disabled'] = TRUE; -diff --git a/core/modules/system/src/Tests/Module/ModuleTestBase.php b/core/modules/system/src/Tests/Module/ModuleTestBase.php -index 64f673b68d..7b97c81bcc 100644 ---- a/core/modules/system/src/Tests/Module/ModuleTestBase.php -+++ b/core/modules/system/src/Tests/Module/ModuleTestBase.php -@@ -63,7 +63,7 @@ public function assertTableCount($base_table, $count = TRUE) { - * The name of the module. - */ - public function assertModuleTablesExist($module) { -- $tables = array_keys(drupal_get_module_schema($module)); -+ $tables = array_keys(\Drupal::service('schema_installer')->getSchema($module)); - $tables_exist = TRUE; - $schema = Database::getConnection()->schema(); - foreach ($tables as $table) { -@@ -81,7 +81,7 @@ public function assertModuleTablesExist($module) { - * The name of the module. - */ - public function assertModuleTablesDoNotExist($module) { -- $tables = array_keys(drupal_get_module_schema($module)); -+ $tables = array_keys(\Drupal::service('schema_installer')->getSchema($module)); - $tables_exist = FALSE; - $schema = Database::getConnection()->schema(); - foreach ($tables as $table) { -diff --git a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php -index 673404f41c..28f514f39d 100644 ---- a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php -+++ b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php -@@ -278,9 +278,12 @@ protected function runUpdates() { - } } - } -- // Reset the static cache of drupal_get_installed_schema_version() so that -+ // Reset the static cache of installed schema versions so that - // more complex update path testing works. -- drupal_static_reset('drupal_get_installed_schema_version'); -+ /** @var \Drupal\Core\Extension\SchemaInstallerInterface $schema_installer */ -+ $schema_installer = \Drupal::service('schema_installer'); -+ $schema_installer->resetCache(); -+ $schema_installer->getInstalledVersions(); - - // The config schema can be incorrect while the update functions are being - // executed. But once the update has been completed, it needs to be valid diff --git a/core/modules/system/system.install b/core/modules/system/system.install -index 69433cf897..9aeb5980c9 100644 +index 89335d0136..1e68600a42 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install -@@ -777,10 +777,12 @@ function system_requirements($phase) { +@@ -771,10 +771,12 @@ function system_requirements($phase) { // Check installed modules. $has_pending_updates = FALSE; @@ -1178,10 +1029,10 @@ ->fields([ 'data' => $schema['fields']['data']['type'], diff --git a/core/modules/system/tests/src/Functional/Module/InstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallTest.php -index 43b66782f3..ac90aac753 100644 +index e6a83e9323..0812ed7abc 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallTest.php -@@ -46,9 +46,13 @@ public function testEnableUserTwice() { +@@ -51,9 +51,13 @@ public function testEnableUserTwice() { * Tests recorded schema versions of early installed modules in the installer. */ public function testRequiredModuleSchemaVersions() { @@ -1198,7 +1049,7 @@ $post_update_key_value = \Drupal::keyValue('post_update'); diff --git a/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php b/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php -index 88007a05b8..50925f2cd1 100644 +index e83f558df1..da4f6a14d1 100644 --- a/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php +++ b/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php @@ -56,7 +56,7 @@ public function assertTableCount($base_table, $count = TRUE) { @@ -1220,10 +1071,10 @@ $schema = Database::getConnection()->schema(); foreach ($tables as $table) { diff --git a/core/modules/system/tests/src/Functional/System/StatusTest.php b/core/modules/system/tests/src/Functional/System/StatusTest.php -index 845b5a8e92..9ad35f7507 100644 +index 770453a881..5e8965fb75 100644 --- a/core/modules/system/tests/src/Functional/System/StatusTest.php +++ b/core/modules/system/tests/src/Functional/System/StatusTest.php -@@ -63,12 +63,12 @@ public function testStatusPage() { +@@ -68,12 +68,12 @@ public function testStatusPage() { // Set the schema version of update_test_postupdate to a lower version, so // update_test_postupdate_update_8001() needs to be executed. @@ -1238,24 +1089,11 @@ /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */ $post_update_registry = \Drupal::service('update.post_update_registry'); $post_update_registry->filterOutInvokedUpdatesByModule('update_test_postupdate'); -diff --git a/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php b/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php -index af2552492a..e15d6fbedb 100644 ---- a/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php -+++ b/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php -@@ -39,7 +39,7 @@ public function testDatabaseLoaded() { - 'system' => '8013', - ]; - foreach ($hook_updates as $module => $schema) { -- $this->assertEqual(drupal_get_installed_schema_version($module), $schema, new FormattableMarkup('Module @module schema is @schema', ['@module' => $module, '@schema' => $schema])); -+ $this->assertEqual(\Drupal::service('schema_installer')->getInstalledVersion($module), $schema, new FormattableMarkup('Module @module schema is @schema', ['@module' => $module, '@schema' => $schema])); - } - - // Test post_update key value stores contains a list of the update functions -diff --git a/core/modules/system/tests/src/Functional/Update/UpdateSchemaTest.php b/core/modules/system/tests/src/Functional/Update/UpdateSchemaTest.php -index aa28be020d..e57bf38fe1 100644 ---- a/core/modules/system/tests/src/Functional/Update/UpdateSchemaTest.php -+++ b/core/modules/system/tests/src/Functional/Update/UpdateSchemaTest.php -@@ -49,9 +49,11 @@ protected function setUp() { +diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php +index 95efd30eac..2859259ffe 100644 +--- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php ++++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateSchemaTest.php +@@ -54,9 +54,11 @@ protected function setUp(): void { */ public function testUpdateHooks() { $connection = Database::getConnection(); @@ -1268,7 +1106,7 @@ $this->assertFalse($connection->schema()->indexExists('update_test_schema_table', 'test'), 'Version 8000 of the update_test_schema module is installed.'); // Increment the schema version. -@@ -67,7 +69,8 @@ public function testUpdateHooks() { +@@ -72,7 +74,8 @@ public function testUpdateHooks() { $this->checkForMetaRefresh(); // Ensure schema has changed. @@ -1278,7 +1116,7 @@ // Ensure the index was added for column a. $this->assertTrue($connection->schema()->indexExists('update_test_schema_table', 'test'), 'Version 8001 of the update_test_schema module is installed.'); -@@ -75,7 +78,7 @@ public function testUpdateHooks() { +@@ -80,7 +83,7 @@ public function testUpdateHooks() { require_once $this->root . '/core/includes/update.inc'; update_set_schema('update_test_schema', 8003); // Ensure schema has changed. @@ -1287,19 +1125,19 @@ } -diff --git a/core/modules/system/tests/src/Functional/Update/UpdateScriptTest.php b/core/modules/system/tests/src/Functional/Update/UpdateScriptTest.php -index 162cbf482c..0700db4a65 100644 ---- a/core/modules/system/tests/src/Functional/Update/UpdateScriptTest.php -+++ b/core/modules/system/tests/src/Functional/Update/UpdateScriptTest.php +diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php +index b1860a305e..d57446e05e 100644 +--- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php ++++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php @@ -2,6 +2,7 @@ - namespace Drupal\Tests\system\Functional\Update; + namespace Drupal\Tests\system\Functional\UpdateSystem; +use Drupal\Core\Extension\SchemaInstallerInterface; + use Drupal\Component\Serialization\Yaml; use Drupal\Core\Url; use Drupal\language\Entity\ConfigurableLanguage; - use Drupal\Tests\BrowserTestBase; -@@ -116,7 +117,7 @@ public function testRequirements() { +@@ -142,7 +143,7 @@ public function testRequirements() { // successfully. $this->drupalLogin($this->updateUser); $update_script_test_config->set('requirement_type', REQUIREMENT_WARNING)->save(); @@ -1308,7 +1146,7 @@ $this->drupalGet($this->updateUrl, ['external' => TRUE]); $this->assertText('This is a requirements warning provided by the update_script_test module.'); $this->clickLink('try again'); -@@ -214,12 +215,16 @@ public function testSuccessfulUpdateFunctionality() { +@@ -486,12 +487,16 @@ public function testSuccessfulUpdateFunctionality() { $this->assertEqual($final_maintenance_mode, $initial_maintenance_mode, 'Maintenance mode should not have changed after database updates.'); // Reset the static cache to ensure we have the most current setting. @@ -1328,7 +1166,7 @@ $this->assertEqual($schema_version, 8000, 'update_script_test schema version overridden to 8000.'); // Click through update.php with 'access administration pages' and -@@ -274,12 +279,16 @@ public function testSuccessfulMultilingualUpdateFunctionality() { +@@ -546,12 +551,16 @@ public function testSuccessfulMultilingualUpdateFunctionality() { $config->save(); // Reset the static cache to ensure we have the most current setting. @@ -1348,7 +1186,7 @@ $this->assertEqual($schema_version, 8000, 'update_script_test schema version overridden to 8000.'); // Create admin user. -@@ -311,12 +320,15 @@ public function testSuccessfulMultilingualUpdateFunctionality() { +@@ -583,12 +592,15 @@ public function testSuccessfulMultilingualUpdateFunctionality() { * Helper function to run updates via the browser. */ protected function runUpdates($maintenance_mode) { @@ -1367,11 +1205,11 @@ $this->assertEqual($schema_version, 8000, 'update_script_test schema version overridden to 8000.'); // Click through update.php with 'administer software updates' permission. -diff --git a/core/modules/system/tests/src/Functional/Update/UpdatesWith7xTest.php b/core/modules/system/tests/src/Functional/Update/UpdatesWith7xTest.php -index e4c5635928..c45b3e8422 100644 ---- a/core/modules/system/tests/src/Functional/Update/UpdatesWith7xTest.php -+++ b/core/modules/system/tests/src/Functional/Update/UpdatesWith7xTest.php -@@ -44,11 +44,11 @@ protected function setUp() { +diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php +index 27e721b762..9efff4b26a 100644 +--- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php ++++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatesWith7xTest.php +@@ -49,11 +49,11 @@ protected function setUp(): void { public function testWith7x() { // Ensure that the minimum schema version is 8000, despite 7200 update // hooks and a 7XXX hook_update_last_removed(). @@ -1386,7 +1224,7 @@ // Click through update.php with 'administer software updates' permission. $this->drupalLogin($this->updateUser); diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php -index 698de170a6..e4a97995fb 100644 +index c1e2618795..02b8380be8 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -5,6 +5,7 @@ @@ -1407,18 +1245,9 @@ - $this->assertEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, "$module module was uninstalled."); + $this->assertEqual($schema_installer->getInstalledVersion($module), SchemaInstallerInterface::UNINSTALLED, "$module module was uninstalled."); } - $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: []; + $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order', []); $this->assertEqual($uninstalled_modules, ['color', 'config', 'help'], 'Modules were uninstalled in the correct order.'); -@@ -180,7 +183,7 @@ public function testUninstallProfileDependencyBC() { - $result = $this->moduleInstaller()->uninstall([$dependency]); - $this->assertTrue($result, 'ModuleInstaller::uninstall() returns TRUE.'); - $this->assertFalse($this->moduleHandler()->moduleExists($dependency)); -- $this->assertEqual(drupal_get_installed_schema_version($dependency), SCHEMA_UNINSTALLED, "$dependency module was uninstalled."); -+ $this->assertEqual(\Drupal::service('schema_installer')->getInstalledVersion($dependency), SchemaInstallerInterface::UNINSTALLED, "$dependency module was uninstalled."); - - // Verify that the installation profile itself was not uninstalled. - $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: []; -@@ -215,7 +218,7 @@ public function testUninstallProfileDependency() { +@@ -177,7 +180,7 @@ public function testUninstallProfileDependency() { $result = $this->moduleInstaller()->uninstall([$non_dependency]); $this->assertTrue($result, 'ModuleInstaller::uninstall() returns TRUE.'); $this->assertFalse($this->moduleHandler()->moduleExists($non_dependency)); @@ -1426,8 +1255,8 @@ + $this->assertEquals(\Drupal::service('schema_installer')->getInstalledVersion($non_dependency), SchemaInstallerInterface::UNINSTALLED, "$non_dependency module was uninstalled."); // Verify that the installation profile itself was not uninstalled. - $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: []; -@@ -310,7 +313,7 @@ public function testUninstallContentDependency() { + $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order', []); +@@ -272,7 +275,7 @@ public function testUninstallContentDependency() { $result = $this->moduleInstaller()->uninstall(['help']); $this->assertTrue($result, 'ModuleInstaller::uninstall() returns TRUE.'); @@ -1437,23 +1266,24 @@ /** diff --git a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php -index 504eb96ab9..a1ee16676f 100644 +index 285906f752..ac19cc44aa 100644 --- a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php +++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php -@@ -36,9 +36,10 @@ protected function setDatabaseDumpFiles() { +@@ -34,9 +34,11 @@ protected function setDatabaseDumpFiles() { public function testDatabaseLoaded() { // Set a value in the cache to prove caches are cleared. \Drupal::service('cache.default')->set(__CLASS__, 'Test'); - + /** @var \Drupal\Core\Extension\SchemaInstallerInterface $schema_installer */ + $schema_installer = \Drupal::service('schema_installer'); - foreach (['user', 'node', 'system', 'update_test_schema'] as $module) { -- $this->assertEqual(drupal_get_installed_schema_version($module), 8000, new FormattableMarkup('Module @module schema is 8000', ['@module' => $module])); -+ $this->assertEqual($schema_installer->getInstalledVersion($module), 8000, new FormattableMarkup('Module @module schema is 8000', ['@module' => $module])); + foreach (['user' => 8100, 'node' => 8700, 'system' => 8805, 'update_test_schema' => 8000] as $module => $schema) { +- $this->assertEqual(drupal_get_installed_schema_version($module), $schema, new FormattableMarkup('Module @module schema is @schema', ['@module' => $module, '@schema' => $schema])); ++ $this->assertEqual($schema_installer->getInstalledVersion($module), $schema, new FormattableMarkup('Module @module schema is @schema', ['@module' => $module, '@schema' => $schema])); ++ } // Ensure that all {router} entries can be unserialized. If they cannot be -@@ -99,8 +100,11 @@ public function testUpdateHookN() { +@@ -98,8 +100,11 @@ public function testUpdateHookN() { $this->assertEqual([], $container_cannot_be_saved_messages); // Ensure schema has changed. @@ -1489,67 +1319,11 @@ $job = $this->connection->query('SELECT job FROM {test} WHERE id = :id', [':id' => $id])->fetchField(); $this->assertEqual($job, $schema['fields']['job']['default'], 'Default field value is set.'); -diff --git a/core/tests/Drupal/KernelTests/Core/Extension/SchemaDeprecationTest.php b/core/tests/Drupal/KernelTests/Core/Extension/SchemaDeprecationTest.php -new file mode 100644 -index 0000000000..aaaeeb2438 ---- /dev/null -+++ b/core/tests/Drupal/KernelTests/Core/Extension/SchemaDeprecationTest.php -@@ -0,0 +1,50 @@ -+assertEquals(SCHEMA_UNINSTALLED, drupal_get_installed_schema_version('dblog')); -+ drupal_set_installed_schema_version('dblog', '1'); -+ $this->assertEquals('1', drupal_get_installed_schema_version('dblog')); -+ } -+ -+ /** -+ * @expectedDeprecation drupal_install_schema() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::install() instead. See https://www.drupal.org/node/2970993 -+ * @expectedDeprecation drupal_get_module_schema() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::uninstall() instead. See https://www.drupal.org/node/2970993 -+ * @expectedDeprecation drupal_uninstall_schema() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\SchemaInstallerInterface::uninstall() instead. See https://www.drupal.org/node/2970993 -+ */ -+ public function testDeprecatedInstallSchema() { -+ drupal_install_schema('dblog'); -+ $this->assertEquals('watchdog', key(drupal_get_module_schema('dblog'))); -+ drupal_uninstall_schema('dblog'); -+ } -+ -+ /** -+ * @expectedDeprecation _drupal_schema_initialize() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. No direct replacement provided. See https://www.drupal.org/node/2970993 -+ */ -+ public function testDeprecatedSchemaInitialize() { -+ $module = 'dblog'; -+ $table = 'watchdog'; -+ $schema = [$table => []]; -+ _drupal_schema_initialize($schema, $module, FALSE); -+ $this->assertEquals($module, $schema[$table]['module']); -+ $this->assertEquals($table, $schema[$table]['name']); -+ } -+ -+} diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php -index ad46657cf6..a14f9d0e0a 100644 +index b1ebad5e32..4b5752c15f 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php -@@ -702,8 +702,9 @@ protected function installSchema($module, $tables) { +@@ -708,8 +708,9 @@ protected function installSchema($module, $tables) { throw new \LogicException("$module module is not enabled."); } $tables = (array) $tables; @@ -1558,5 +1332,5 @@ - $schema = drupal_get_module_schema($module, $table); + $schema = $schema_installer->getSchema($module, $table); if (empty($schema)) { - // BC layer to avoid some contrib tests to fail. - if ($module == 'system') { + throw new \LogicException("$module module does not define a schema for table '$table'."); + }