diff --git a/core/includes/common.inc b/core/includes/common.inc index 53e0be5..7420d02 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1120,7 +1120,7 @@ function drupal_flush_all_caches() { PhpStorageFactory::get('twig')->deleteAll(); // Rebuild module and theme data. - $module_data = system_rebuild_module_data(); + $module_data = \Drupal::service('extension.list.module')->reset()->getList(); /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ $theme_handler = \Drupal::service('theme_handler'); $theme_handler->refreshInfo(); diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index b4c731d..e39e687 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1501,7 +1501,7 @@ function install_profile_modules(&$install_state) { install_core_entity_type_definitions(); $modules = \Drupal::state()->get('install_profile_modules') ?: []; - $files = system_rebuild_module_data(); + $files = $this->container->get('extension.list.module')->getList(); \Drupal::state()->delete('install_profile_modules'); // Always install required modules first. Respect the dependencies between diff --git a/core/includes/update.inc b/core/includes/update.inc index d7fe942..7e5eb99 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -43,7 +43,7 @@ function update_check_incompatibility($name, $type = 'module') { // code changes that were made in the filesystem before the update script // was initiated. $themes = \Drupal::service('theme_handler')->rebuildThemeData(); - $modules = system_rebuild_module_data(); + $modules = \Drupal::service('extension.list.module')->reset()->getList(); } if ($type == 'module' && isset($modules[$name])) { diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index b58f963..c1e50ec 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -369,7 +369,7 @@ protected function createExtensionChangelist() { } // Get a list of modules with dependency weights as values. - $module_data = system_rebuild_module_data(); + $module_data = \Drupal::service('extension.list.module')->getList(); // Set the actual module weights. $module_list = array_combine(array_keys($module_data), array_keys($module_data)); $module_list = array_map(function ($module) use ($module_data) { diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php index ea7d29f..fe5bdfb 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php @@ -303,7 +303,7 @@ protected function getThemeData() { */ protected function getModuleData() { if (!isset($this->moduleData)) { - $this->moduleData = system_rebuild_module_data(); + $this->moduleData = \Drupal::service('extension.list.module')->getList(); } return $this->moduleData; } diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 2cf34bd..c01aaa0 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -83,7 +83,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { $extension_config = \Drupal::configFactory()->getEditable('core.extension'); if ($enable_dependencies) { // Get all module data so we can find dependencies and sort. - $module_data = system_rebuild_module_data(); + $module_data = \Drupal::service('extension.list.module')->reset()->getList(); $module_list = $module_list ? array_combine($module_list, $module_list) : []; if ($missing_modules = array_diff_key($module_list, $module_data)) { // One or more of the given modules doesn't exist. @@ -329,7 +329,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { */ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // Get all module data so we can find dependencies and sort. - $module_data = system_rebuild_module_data(); + $module_data = \Drupal::service('extension.list.module')->getList(); $module_list = $module_list ? array_combine($module_list, $module_list) : []; if (array_diff_key($module_list, $module_data)) { // One or more of the given modules doesn't exist. diff --git a/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php b/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php index d3fa533..8b90f0d 100644 --- a/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php +++ b/core/lib/Drupal/Core/Extension/RequiredModuleUninstallValidator.php @@ -44,7 +44,7 @@ public function validate($module) { * The module info, or NULL if that module does not exist. */ protected function getModuleInfoByModule($module) { - $modules = system_rebuild_module_data(); + $modules = \Drupal::service('extension.list.module')->getList(); return isset($modules[$module]->info) ? $modules[$module]->info : []; } diff --git a/core/lib/Drupal/Core/Extension/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php index 45355cc..e39c341 100644 --- a/core/lib/Drupal/Core/Extension/module.api.php +++ b/core/lib/Drupal/Core/Extension/module.api.php @@ -131,7 +131,7 @@ function hook_module_implements_alter(&$implementations, $hook) { /** * Alter the information parsed from module and theme .info.yml files. * - * This hook is invoked in _system_rebuild_module_data() and in + * This hook is invoked in \Drupal\Core\Extension\ExtensionList::getList() and in * \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData(). A module * may implement this hook in order to add to or alter the data generated by * reading the .info.yml file with \Drupal\Core\Extension\InfoParser. diff --git a/core/modules/config/tests/src/Functional/ConfigImportAllTest.php b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php index 4823e6b..dcff131 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportAllTest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php @@ -47,7 +47,7 @@ protected function setUp() { public function testInstallUninstall() { // Get a list of modules to enable. - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->getList(); $all_modules = array_filter($all_modules, function ($module) { // Filter contrib, hidden, already enabled modules and modules in the // Testing package. @@ -94,7 +94,7 @@ public function testInstallUninstall() { entity_delete_multiple('shortcut', array_keys($shortcuts)); system_list_reset(); - $all_modules = system_rebuild_module_data(); + $all_modules = \Drupal::service('extension.list.module')->reset()->getList(); // Ensure that only core required modules and the install profile can not be uninstalled. $validation_reasons = \Drupal::service('module_installer')->validateUninstall(array_keys($all_modules)); diff --git a/core/modules/config/tests/src/Functional/ConfigImportUITest.php b/core/modules/config/tests/src/Functional/ConfigImportUITest.php index fd76990..a6ce280 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportUITest.php @@ -498,7 +498,7 @@ public function testExtensionValidation() { $core = $sync->read('core.extension'); // Node depends on text. unset($core['module']['text']); - $module_data = system_rebuild_module_data(); + $module_data = $this->container->get('extension.list.module')->getList(); $this->assertTrue(isset($module_data['node']->requires['text']), 'The Node module depends on the Text module.'); // Bartik depends on classy. unset($core['theme']['classy']); diff --git a/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php b/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php index afd468a..a4a0f10 100644 --- a/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php +++ b/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php @@ -197,7 +197,7 @@ protected function checkDisplayOption($entity_type_id, $field_id, BaseFieldDefin * and all modules required by any of these modules. */ protected function modulesWithSubdirectory($subdirectory) { - $modules = system_rebuild_module_data(); + $modules = $this->container->get('extension.list.module')->getList(); $modules = array_filter($modules, function (Extension $module) use ($subdirectory) { // Filter contrib, hidden, already enabled modules and modules in the // Testing package. diff --git a/core/modules/help/tests/src/Functional/HelpTest.php b/core/modules/help/tests/src/Functional/HelpTest.php index dff11ef..0946ac6 100644 --- a/core/modules/help/tests/src/Functional/HelpTest.php +++ b/core/modules/help/tests/src/Functional/HelpTest.php @@ -152,7 +152,7 @@ protected function verifyHelp($response = 200) { */ protected function getModuleList() { $modules = []; - $module_data = system_rebuild_module_data(); + $module_data = $this->container->get('extension.list.module')->getList(); foreach (\Drupal::moduleHandler()->getImplementations('help') as $module) { $modules[$module] = $module_data[$module]->info['name']; } diff --git a/core/modules/help/tests/src/Kernel/HelpEmptyPageTest.php b/core/modules/help/tests/src/Kernel/HelpEmptyPageTest.php index 070a954..61e1a7c 100644 --- a/core/modules/help/tests/src/Kernel/HelpEmptyPageTest.php +++ b/core/modules/help/tests/src/Kernel/HelpEmptyPageTest.php @@ -32,7 +32,7 @@ public function register(ContainerBuilder $container) { * Ensures that no URL generator is called on a page without hook_help(). */ public function testEmptyHookHelp() { - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->getList();; $all_modules = array_filter($all_modules, function ($module) { // Filter contrib, hidden, already enabled modules and modules in the // Testing package. diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc index c66af14..1c42b7e 100644 --- a/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -103,7 +103,7 @@ function locale_translation_project_list() { 'interface translation project', 'interface translation server pattern', ]; - $module_data = _locale_translation_prepare_project_list(system_rebuild_module_data(), 'module'); + $module_data = _locale_translation_prepare_project_list(\Drupal::service('extension.list.module')->getList(), 'module'); $theme_data = _locale_translation_prepare_project_list(\Drupal::service('theme_handler')->rebuildThemeData(), 'theme'); $project_info = new ProjectInfo(); $project_info->processInfoList($projects, $module_data, 'module', TRUE, $additional_whitelist); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceRestTestCoverageTest.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceRestTestCoverageTest.php index d10d55c..78ca44f 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceRestTestCoverageTest.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceRestTestCoverageTest.php @@ -28,7 +28,7 @@ class EntityResourceRestTestCoverageTest extends BrowserTestBase { protected function setUp() { parent::setUp(); - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->getList();; $stable_core_modules = array_filter($all_modules, function ($module) { // Filter out contrib, hidden, testing, and experimental modules. We also // don't need to enable modules that are already enabled. diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index 3ff6c3d..195b15e 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -143,7 +143,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ]; // Sort all modules by their names. - $modules = system_rebuild_module_data(); + $modules = \Drupal::service('extension.list.module')->getList(); uasort($modules, 'system_sort_modules_by_info_name'); // Iterate over each of the modules. @@ -368,7 +368,7 @@ protected function buildModuleList(FormStateInterface $form_state) { 'experimental' => [], ]; - $data = system_rebuild_module_data(); + $data = \Drupal::service('extension.list.module')->getList(); foreach ($data as $name => $module) { // If the module is installed there is nothing to do. if ($this->moduleHandler->moduleExists($name)) { diff --git a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php index f55f0d6..1caa8d1 100644 --- a/core/modules/system/src/Form/ModulesUninstallConfirmForm.php +++ b/core/modules/system/src/Form/ModulesUninstallConfirmForm.php @@ -135,7 +135,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { return $this->redirect('system.modules_uninstall'); } - $data = system_rebuild_module_data(); + $data = \Drupal::service('extension.list.module')->getList(); $form['text']['#markup'] = '

' . $this->t('The following modules will be completely uninstalled from your site, and all data from these modules will be lost!') . '

'; $form['modules'] = [ '#theme' => 'item_list', diff --git a/core/modules/system/src/Form/ModulesUninstallForm.php b/core/modules/system/src/Form/ModulesUninstallForm.php index 7949067..9fcefc3 100644 --- a/core/modules/system/src/Form/ModulesUninstallForm.php +++ b/core/modules/system/src/Form/ModulesUninstallForm.php @@ -79,7 +79,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { include_once DRUPAL_ROOT . '/core/includes/install.inc'; // Get a list of all available modules. - $modules = system_rebuild_module_data(); + $modules = \Drupal::service('extension.list.module')->getList(); $uninstallable = array_filter($modules, function ($module) use ($modules) { return empty($modules[$module->getName()]->info['required']) && $module->status; }); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 0fd4b26..0d7a550 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -780,7 +780,7 @@ function system_requirements($phase) { // Display an error if a newly introduced dependency in a module is not resolved. if ($phase == 'update') { $profile = drupal_get_profile(); - $files = system_rebuild_module_data(); + $files = \Drupal::service('extension.list.module')->getList(); foreach ($files as $module => $file) { // Ignore disabled modules and installation profiles. if (!$file->status || $module == $profile) { diff --git a/core/modules/system/system.module b/core/modules/system/system.module index bb82d4b..386d80b 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -955,7 +955,7 @@ function system_check_directory($form_element, FormStateInterface $form_state) { * information for $name, if given. If no records are available, an empty * array is returned. * - * @see system_rebuild_module_data() + * @see \Drupal\Core\Extension\ModuleExtensionList::getList() * @see \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData() */ function system_get_info($type, $name = NULL) { diff --git a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php index 4d8f30d..ac6685a 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php @@ -33,7 +33,7 @@ public function testInstallUninstall() { $this->assertEqual($this->container->get('state')->get('system_test_preuninstall_module'), 'module_test'); $this->resetAll(); - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->reset()->getList(); // Test help on required modules, but do not test uninstalling. $required_modules = array_filter($all_modules, function ($module) { diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index a8767e9..30d3c3d 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -25,14 +25,7 @@ class ModuleHandlerTest extends KernelTestBase { protected function setUp() { parent::setUp(); - // @todo ModuleInstaller calls system_rebuild_module_data which is part of - // system.module, see https://www.drupal.org/node/2208429. - include_once $this->root . '/core/modules/system/system.module'; - - // Set up the state values so we know where to find the files when running - // drupal_get_filename(). - // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->getList(); } /** @@ -259,7 +252,7 @@ public function testUninstallContentDependency() { */ public function testModuleMetaData() { // Generate the list of available modules. - $modules = system_rebuild_module_data(); + $modules = $this->container->get('extension.list.module')->getList(); // Check that the mtime field exists for the system module. $this->assertTrue(!empty($modules['system']->info['mtime']), 'The system.info.yml file modification time field is present.'); // Use 0 if mtime isn't present, to avoid an array index notice. diff --git a/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php b/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php index ebdac3c..ee5fbf6 100644 --- a/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php +++ b/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php @@ -22,14 +22,14 @@ class InfoAlterTest extends KernelTestBase { */ public function testSystemInfoAlter() { \Drupal::state()->set('module_required_test.hook_system_info_alter', TRUE); - $info = system_rebuild_module_data(); + $info = \Drupal::service('extension.list.module')->getList(); $this->assertFalse(isset($info['node']->info['required']), 'Before the module_required_test is installed the node module is not required.'); // Enable the test module. \Drupal::service('module_installer')->install(['module_required_test'], FALSE); $this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_required_test'), 'Test required module is enabled.'); - $info = system_rebuild_module_data(); + $info = \Drupal::service('extension.list.module')->getList(); $this->assertTrue($info['node']->info['required'], 'After the module_required_test is installed the node module is required.'); } diff --git a/core/modules/update/src/UpdateManager.php b/core/modules/update/src/UpdateManager.php index 0741691..bc1c491 100644 --- a/core/modules/update/src/UpdateManager.php +++ b/core/modules/update/src/UpdateManager.php @@ -129,7 +129,7 @@ public function getProjects() { $this->projects = $this->projectStorage('update_project_projects'); if (empty($this->projects)) { // Still empty, so we have to rebuild. - $module_data = system_rebuild_module_data(); + $module_data = \Drupal::service('extension.list.module')->getList(); $theme_data = $this->themeHandler->rebuildThemeData(); $project_info = new ProjectInfo(); $project_info->processInfoList($this->projects, $module_data, 'module', TRUE); diff --git a/core/modules/update/tests/src/Functional/UpdateContribTest.php b/core/modules/update/tests/src/Functional/UpdateContribTest.php index 20d397c..343a157 100644 --- a/core/modules/update/tests/src/Functional/UpdateContribTest.php +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php @@ -120,7 +120,7 @@ public function testUpdateContribBasic() { * project. We need to make sure that we see the "BBB" project before the * "CCC" project, even though "CCC" includes a module that's processed first * if you sort alphabetically by module name (which is the order we see things - * inside system_rebuild_module_data() for example). + * inside \Drupal\Core\Extension\ExtensionList::getList() for example). */ public function testUpdateContribOrder() { // We want core to be version 8.0.0. diff --git a/core/modules/user/src/PermissionHandler.php b/core/modules/user/src/PermissionHandler.php index 1f07b25..056c435 100644 --- a/core/modules/user/src/PermissionHandler.php +++ b/core/modules/user/src/PermissionHandler.php @@ -229,13 +229,4 @@ protected function getModuleNames() { return $modules; } - /** - * Wraps system_rebuild_module_data() - * - * @return \Drupal\Core\Extension\Extension[] - */ - protected function systemRebuildModuleData() { - return system_rebuild_module_data(); - } - } diff --git a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php index 2918d2f..94791ce 100644 --- a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php +++ b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php @@ -29,7 +29,7 @@ class PermissionHandlerTest extends UnitTestCase { /** * The tested permission handler. * - * @var \Drupal\Tests\user\Unit\TestPermissionHandler|\Drupal\user\PermissionHandler + * @var \Drupal\user\PermissionHandler */ protected $permissionHandler; @@ -142,10 +142,7 @@ public function testBuildPermissionsYaml() { $this->controllerResolver->expects($this->never()) ->method('getControllerFromDefinition'); - $this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); - - // Setup system_rebuild_module_data(). - $this->permissionHandler->setSystemRebuildModuleData($extensions); + $this->permissionHandler = new PermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); $actual_permissions = $this->permissionHandler->getPermissions(); $this->assertPermissions($actual_permissions); @@ -206,7 +203,7 @@ public function testBuildPermissionsSortPerModule() { ->method('getModuleList') ->willReturn(array_flip($modules)); - $permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); + $permissionHandler = new PermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); $actual_permissions = $permissionHandler->getPermissions(); $this->assertEquals(['access_module_a4', 'access_module_a1', 'access_module_a2', 'access_module_a3'], array_keys($actual_permissions)); @@ -287,10 +284,7 @@ public function testBuildPermissionsYamlCallback() { ->with('Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescriptionRestrictAccess') ->willReturn([new TestPermissionCallbacks(), 'titleDescriptionRestrictAccess']); - $this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); - - // Setup system_rebuild_module_data(). - $this->permissionHandler->setSystemRebuildModuleData($extensions); + $this->permissionHandler = new PermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); $actual_permissions = $this->permissionHandler->getPermissions(); $this->assertPermissions($actual_permissions); @@ -341,10 +335,7 @@ public function testPermissionsYamlStaticAndCallback() { ->with('Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescription') ->willReturn([new TestPermissionCallbacks(), 'titleDescription']); - $this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); - - // Setup system_rebuild_module_data(). - $this->permissionHandler->setSystemRebuildModuleData($extensions); + $this->permissionHandler = new PermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); $actual_permissions = $this->permissionHandler->getPermissions(); @@ -377,25 +368,6 @@ protected function assertPermissions(array $actual_permissions) { } -class TestPermissionHandler extends PermissionHandler { - - /** - * Test module data. - * - * @var array - */ - protected $systemModuleData; - - protected function systemRebuildModuleData() { - return $this->systemModuleData; - } - - public function setSystemRebuildModuleData(array $extensions) { - $this->systemModuleData = $extensions; - } - -} - class TestPermissionCallbacks { public function singleDescription() { diff --git a/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php b/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php index 39a5acc..79da3b3 100644 --- a/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php +++ b/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php @@ -50,14 +50,7 @@ class DefaultConfigTest extends KernelTestBase { protected function setUp() { parent::setUp(); - // @todo ModuleInstaller calls system_rebuild_module_data which is part of - // system.module, see https://www.drupal.org/node/2208429. - include_once $this->root . '/core/modules/system/system.module'; - - // Set up the state values so we know where to find the files when running - // drupal_get_filename(). - // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->reset(); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php index 2131a35..5717c52 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php @@ -99,7 +99,7 @@ protected function setUp() { $this->container->get('theme_installer')->install($this->allThemes); // Enable all core modules. - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->reset()->getList(); $all_modules = array_filter($all_modules, function ($module) { // Filter contrib, hidden, already enabled modules and modules in the // Testing package. diff --git a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php index 396facf..4845f4f 100644 --- a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php +++ b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php @@ -30,10 +30,8 @@ public function register(ContainerBuilder $container) { * Tests that drupal_get_filename() works when the file is not in database. */ public function testDrupalGetFilename() { - // Rebuild system.module.files state data. - // @todo Remove as part of https://www.drupal.org/node/2186491 - drupal_static_reset('system_rebuild_module_data'); - system_rebuild_module_data(); + // Rebuild module list state data. + \Drupal::service('extension.list.module')->reset(); // Retrieving the location of a module. $this->assertIdentical(drupal_get_filename('module', 'system'), 'core/modules/system/system.info.yml'); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php index a9cd9f1..453176e 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigDependencyTest.php @@ -219,8 +219,7 @@ public function testConfigEntityUninstall() { $entity2->save(); // Perform a module rebuild so we can know where the node module is located // and uninstall it. - // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->reset(); // Test that doing a config uninstall of the node module deletes entity2 // since it is dependent on entity1 which is dependent on the node module. $config_manager->uninstall('module', 'node'); @@ -361,8 +360,7 @@ public function testConfigEntityUninstallComplex(array $entity_id_suffixes) { // Perform a module rebuild so we can know where the node module is located // and uninstall it. - // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->reset(); // Perform the uninstall. $config_manager->uninstall('module', 'node'); @@ -478,8 +476,7 @@ public function testConfigEntityUninstallThirdParty() { // Perform a module rebuild so we can know where the node module is located // and uninstall it. - // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->reset(); // Perform the uninstall. $config_manager->uninstall('module', 'node'); diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php index 96e469a..70a6517 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleConfigureRouteTest.php @@ -37,7 +37,7 @@ class ModuleConfigureRouteTest extends KernelTestBase { protected function setUp() { parent::setUp(); $this->routeProvider = \Drupal::service('router.route_provider'); - $this->moduleInfo = system_rebuild_module_data(); + $this->moduleInfo = $this->container->get('extension.list.module')->getList(); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php index ff183c6..bc2a764 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php @@ -16,15 +16,6 @@ class ModuleInstallerTest extends KernelTestBase { /** - * Modules to install. - * - * The System module is required because system_rebuild_module_data() is used. - * - * @var array - */ - public static $modules = ['system']; - - /** * Tests that routes are rebuilt during install and uninstall of modules. * * @covers ::install diff --git a/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php index a71c3fe..300c022 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php @@ -60,7 +60,7 @@ protected function setUp() { $this->container->get('theme_installer')->install(['stable']); // Enable all core modules. - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->getList(); $all_modules = array_filter($all_modules, function ($module) { // Filter contrib, hidden, experimental, already enabled modules, and // modules in the Testing package. diff --git a/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php index 40d31e6..2425287 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php @@ -57,11 +57,8 @@ protected function setUp() { * Installs all core modules. */ protected function installAllModules() { - // Needed for system_rebuild_module_data(). - include_once $this->root . '/core/modules/system/system.module'; - // Enable all core modules. - $all_modules = system_rebuild_module_data(); + $all_modules = $this->container->get('extension.list.module')->getList(); $all_modules = array_filter($all_modules, function ($module) { // Filter contrib, hidden, experimental, already enabled modules, and // modules in the Testing package. diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php index 61f6475..3a049db 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php @@ -316,7 +316,7 @@ public function testThemeInfoAlter() { // Rebuild module data so we know where module_test is located. // @todo Remove as part of https://www.drupal.org/node/2186491 - system_rebuild_module_data(); + $this->container->get('extension.list.module')->reset(); $this->moduleInstaller()->install(['module_test'], FALSE); $this->assertTrue($this->moduleHandler()->moduleExists('module_test'));