diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 87136b6..11462b0 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -888,7 +888,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { else { if ($type == 'module') { if (empty($files[$type])) { - $files[$type] = drupal_extension_handler()->getEnabledModules(); + $files[$type] = drupal_extension_handler()->getModuleList(); } if (isset($files[$type][$name])) { return $files[$type][$name]; diff --git a/core/includes/module.inc b/core/includes/module.inc index 8e950bf..98627c7 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -285,7 +285,7 @@ function module_enable($module_list, $enable_dependencies = TRUE) { $disabled_config = config('system.module.disabled'); $extension_handler = drupal_extension_handler(); foreach ($module_list as $module) { - $module_filenames = $extension_handler->getEnabledModules(); + $module_filenames = $extension_handler->getModuleList(); // Only process modules that are not already enabled. $enabled = isset($module_filenames[$module]); if (!$enabled) { @@ -301,10 +301,15 @@ function module_enable($module_list, $enable_dependencies = TRUE) { ->clear($module) ->save(); - _system_update_bootstrap_status(); - $module_filenames[$module] = drupal_get_filename('module', $module); - // Update the kernel to include it. + + $sorted_modules = $module_config->get('enabled'); + $sorted_with_filenames = array(); + foreach (array_keys($sorted_modules) as $m) { + $filename = isset($module_filenames[$m]) ? $module_filenames[$m] : drupal_get_filename('module', $module); + $sorted_with_filenames[$m] = $filename; + } + // Refresh the module list in the extension handler. $extension_handler->setModuleList($module_filenames); @@ -321,7 +326,7 @@ function module_enable($module_list, $enable_dependencies = TRUE) { // @todo The if statement is here because install_begin_request() creates // a container without a kernel. It probably shouldn't. if ($kernel = drupal_container()->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) { - $kernel->updateModules($sorted_modules, $module_filenames); + $kernel->updateModules($sorted_modules, $sorted_with_filenames); } // Refresh the schema to include it. @@ -433,7 +438,7 @@ function module_disable($module_list, $disable_dependents = TRUE) { $disabled_config = config('system.module.disabled'); $extension_handler = drupal_extension_handler(); foreach ($module_list as $module) { - $enabled = $extension_handler->getEnabledModules(); + $enabled = $extension_handler->getModuleList(); if (isset($enabled[$module])) { module_load_install($module); module_invoke($module, 'disable'); @@ -656,13 +661,13 @@ function module_set_weight($module, $weight) { // Update the module weight in the config file that contains it. $module_config = config('system.module'); $extension_handler = drupal_extension_handler(); - $enabled_modules = $extension_handler->getEnabledModules(); + $enabled_modules = $extension_handler->getModuleList(); if ($module_config->get("enabled.$module") !== NULL) { - $sorted_modules = module_config_sort($module_config->get('enabled')); $module_config ->set("enabled.$module", $weight) - ->set('enabled', $sorted_modules) + ->set('enabled', module_config_sort($module_config->get('enabled'))) ->save(); + $sorted_modules = $module_config->get('enabled'); $sorted_with_filenames = array(); foreach (array_keys($sorted_modules) as $m) { $sorted_with_filenames[$m] = $enabled_modules[$m]; diff --git a/core/includes/schema.inc b/core/includes/schema.inc index 1d04270..ac610e1 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc @@ -130,7 +130,7 @@ function drupal_get_schema_versions($module) { $updates = &drupal_static(__FUNCTION__, NULL); if (!isset($updates[$module])) { $updates = array(); - foreach (drupal_extension_handler()->getEnabledModules() as $loaded_module => $filename) { + foreach (drupal_extension_handler()->getModuleList() as $loaded_module => $filename) { $updates[$loaded_module] = array(); } diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 8d1c970..0e48cd4 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -511,7 +511,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { // Add all modules so they can intervene with their own variable // processors. This allows them to provide variable processors even // if they are not the owner of the current hook. - $prefixes += array_keys(drupal_extension_handler()->getEnabledModules()); + $prefixes += array_keys(drupal_extension_handler()->getModuleList()); } elseif ($type == 'theme_engine' || $type == 'base_theme_engine') { // Theme engines get an extra set that come before the normally diff --git a/core/includes/update.inc b/core/includes/update.inc index d6b6a3e..ecd1f9f 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -126,7 +126,8 @@ function update_prepare_d8_bootstrap() { include_once DRUPAL_ROOT . '/core/includes/module.inc'; include_once DRUPAL_ROOT . '/core/includes/cache.inc'; - drupal_extension_handler(array('system' => 'core/modules/system/system.module')); + drupal_extension_handler()->setModuleList(array('system' => 'core/modules/system/system.module')); + drupal_extension_handler()->load('system'); // Ensure the configuration directories exist and are writable, or create // them. If the directories have not been specified in settings.php and @@ -240,7 +241,7 @@ function update_prepare_d8_bootstrap() { // Populate a fixed module list (again, why did it get lost?) to avoid // errors due to the drupal_alter() in _system_rebuild_module_data(). - $module_list['system']['filename'] = 'core/modules/system/system.module'; + $module_list['system'] = 'core/modules/system/system.module'; drupal_extension_handler()->setModuleList($module_list); $module_data = _system_rebuild_module_data(); @@ -265,7 +266,14 @@ function update_prepare_d8_bootstrap() { } $schema_store->set($record->name, $record->schema_version); } - $module_config->set('enabled', module_config_sort($module_config->get('enabled')))->save(); + $sorted_modules = module_config_sort($module_config->get('enabled')); + $module_config->set('enabled', $sorted_modules)->save(); + $sorted_with_filenames = array(); + foreach (array_keys($sorted_modules) as $m) { + $sorted_with_filenames[$m] = drupal_get_filename('module', $m); + } + + drupal_extension_handler()->setModuleList($sorted_with_filenames); $disabled_modules->save(); $theme_config->save(); $disabled_themes->save(); diff --git a/core/lib/Drupal/Core/ExtensionHandler.php b/core/lib/Drupal/Core/ExtensionHandler.php index 9170824..488de28 100644 --- a/core/lib/Drupal/Core/ExtensionHandler.php +++ b/core/lib/Drupal/Core/ExtensionHandler.php @@ -115,7 +115,7 @@ public function loadAll($bootstrap = FALSE, $reset = FALSE, $loaded = FALSE) { /** * Implements Drupal\Core\ExtensionHandlerInterface::moduelList(). */ - public function getEnabledModules() { + public function getModuleList() { return $this->moduleList; } @@ -137,7 +137,7 @@ public function getBootstrapModules() { $bootstrap_list = $this->state->get('system.module.bootstrap') ?: array(); $this->bootstrapCache->set('bootstrap_modules', $bootstrap_list); } - // We only return the module names here since getEnabledModules() doesn't need + // We only return the module names here since getModuleList() doesn't need // the filename itself. $this->bootstrapModules = array_keys($bootstrap_list); return $this->bootstrapModules; @@ -400,10 +400,10 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { // appropriate order. $this->moduleImplements() can only return ordered // implementations of a single hook. To get the ordered implementations // of multiple hooks, we mimic the $this->moduleImplements() logic of first - // ordering by $this->getEnabledModules(), and then calling + // ordering by $this->getModuleList(), and then calling // $this->alter('module_implements'). if (array_diff($extra_modules, $modules)) { - // Merge the arrays and order by getEnabledModules(). + // Merge the arrays and order by getModuleList(). $modules = array_intersect(array_keys($this->moduleList), array_merge($modules, $extra_modules)); // Since $this->moduleImplements() already took care of loading the necessary // include files, we can safely pass FALSE for the array values. diff --git a/core/lib/Drupal/Core/ExtensionHandlerInterface.php b/core/lib/Drupal/Core/ExtensionHandlerInterface.php index c9f1391..56076a1 100644 --- a/core/lib/Drupal/Core/ExtensionHandlerInterface.php +++ b/core/lib/Drupal/Core/ExtensionHandlerInterface.php @@ -71,7 +71,7 @@ public function loadAll($bootstrap = FALSE, $reset = FALSE); * * @see self::moduleListReset() */ - public function getEnabledModules(); + public function getModuleList(); /** * Explicitly sets the moduleList property to the passed in array of modules. diff --git a/core/lib/Drupal/Core/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php index 0e8d5b0..e74c4c6 100644 --- a/core/lib/Drupal/Core/Routing/RouteBuilder.php +++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php @@ -85,7 +85,7 @@ public function rebuild() { // We need to manually call each module so that we can know which module // a given item came from. - foreach ($this->extensionHandler->getEnabledModules() as $module => $filename) { + foreach ($this->extensionHandler->getModuleList() as $module => $filename) { $collection = new RouteCollection(); $routing_file = DRUPAL_ROOT . '/' . dirname($filename) . '/' . $module . '.routing.yml'; if (file_exists($routing_file)) { diff --git a/core/modules/breakpoint/breakpoint.install b/core/modules/breakpoint/breakpoint.install index 60ba9cf..dc507d6 100644 --- a/core/modules/breakpoint/breakpoint.install +++ b/core/modules/breakpoint/breakpoint.install @@ -18,5 +18,5 @@ function breakpoint_enable() { _breakpoint_theme_enabled(array_keys($themes)); // Import breakpoints from modules. - _breakpoint_modules_enabled(array_keys(drupal_extension_handler()->getEnabledModules())); + _breakpoint_modules_enabled(array_keys(drupal_extension_handler()->getModuleList())); } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php index ab03d41..4b40e7d 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php @@ -72,6 +72,7 @@ function testCommentEnable() { $edit = array(); $edit['modules[Core][comment][enable]'] = FALSE; $this->drupalPost('admin/modules', $edit, t('Save configuration')); + $this->rebuildContainer(); $this->resetAll(); $this->assertFalse(module_exists('comment'), 'Comment module disabled.'); @@ -80,11 +81,14 @@ function testCommentEnable() { $edit['modules[Core][book][enable]'] = 'book'; $edit['modules[Core][poll][enable]'] = 'poll'; $this->drupalPost('admin/modules', $edit, t('Save configuration')); + $this->rebuildContainer(); // Now enable the comment module. $edit = array(); $edit['modules[Core][comment][enable]'] = 'comment'; $this->drupalPost('admin/modules', $edit, t('Save configuration')); + $this->rebuildContainer(); + $this->resetAll(); $this->assertTrue(module_exists('comment'), 'Comment module enabled.'); diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 87bde70..60672c4 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -504,7 +504,7 @@ function field_modules_disabled($modules) { function field_sync_field_status() { // Refresh the 'active' and 'storage_active' columns according to the current // set of enabled modules. - $modules = array_keys(drupal_extension_handler()->getEnabledModules()); + $modules = array_keys(drupal_extension_handler()->getModuleList()); foreach ($modules as $module_name) { field_associate_fields($module_name); } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php index 436b371..795d4d5 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php @@ -139,7 +139,7 @@ protected function languageNegotiationUpdate($op = 'enable') { $function = "module_{$op}"; $function($modules); // Reset hook implementation cache. - module_implements_reset(); + drupal_container()->get('extension_handler')->moduleImplementsReset(); } drupal_static_reset('language_types_info'); diff --git a/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php index 9f803de..b9feaa0 100644 --- a/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php +++ b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php @@ -61,7 +61,7 @@ public function getDerivativeDefinitions(array $base_plugin_definition) { // Add all modules as possible layout providers. // @todo Change this class so that it gets the extension handler injected // into it. - foreach (drupal_extension_handler()->getEnabledModules() as $module => $filename) { + foreach (drupal_extension_handler()->getModuleList() as $module => $filename) { $available_layout_providers[$module] = array( 'type' => 'module', 'provider' => $module, diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index 5ca7c71..38712d4 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -39,7 +39,7 @@ function testSetUp() { // Verify that specified $modules have been loaded. $this->assertTrue(function_exists('entity_test_permission'), "$module.module was loaded."); // Verify that there is a fixed module list. - $this->assertIdentical(array_keys(drupal_extension_handler()->getEnabledModules()), array($module)); + $this->assertIdentical(array_keys(drupal_extension_handler()->getModuleList()), array($module)); $this->assertIdentical(module_implements('permission'), array($module)); // Verify that no modules have been installed. @@ -54,7 +54,7 @@ function testEnableModulesLoad() { // Verify that the module does not exist yet. $this->assertFalse(module_exists($module), "$module module not found."); - $list = array_keys(drupal_extension_handler()->getEnabledModules()); + $list = array_keys(drupal_extension_handler()->getModuleList()); $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list."); $list = module_implements('permission'); $this->assertFalse(in_array($module, $list), "{$module}_permission() in module_implements() not found."); @@ -64,7 +64,7 @@ function testEnableModulesLoad() { // Verify that the module exists. $this->assertTrue(module_exists($module), "$module module found."); - $list = array_keys(drupal_extension_handler()->getEnabledModules()); + $list = array_keys(drupal_extension_handler()->getModuleList()); $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list."); $list = module_implements('permission'); $this->assertTrue(in_array($module, $list), "{$module}_permission() in module_implements() found."); @@ -83,7 +83,7 @@ function testEnableModulesInstall() { // Verify that the module does not exist yet. $this->assertFalse(module_exists($module), "$module module not found."); - $list = array_keys(drupal_extension_handler()->getEnabledModules()); + $list = array_keys(drupal_extension_handler()->getModuleList()); $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list."); $list = module_implements('permission'); $this->assertFalse(in_array($module, $list), "{$module}_permission() in module_implements() not found."); @@ -97,7 +97,7 @@ function testEnableModulesInstall() { // Verify that the enabled module exists. $this->assertTrue(module_exists($module), "$module module found."); - $list = array_keys(drupal_extension_handler()->getEnabledModules()); + $list = array_keys(drupal_extension_handler()->getModuleList()); $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list."); $list = module_implements('permission'); $this->assertTrue(in_array($module, $list), "{$module}_permission() in module_implements() found."); diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php index 5e28d84..55246fc 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php @@ -40,7 +40,7 @@ function testEnableDisable() { // Remove already enabled modules (via installation profile). // @todo Remove this after removing all dependencies from Testing profile. - foreach ($this->container->get('extension_handler')->getEnabledModules() as $dependency => $filename) { + foreach ($this->container->get('extension_handler')->getModuleList() as $dependency => $filename) { // Exclude required modules. Only installation profile "suggestions" can // be disabled and uninstalled. if (isset($modules[$dependency])) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php index a16c49f..e9b1c3b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php @@ -75,7 +75,7 @@ function testModuleList() { */ protected function assertModuleList(Array $expected_values, $condition) { $expected_values = array_values(array_unique($expected_values)); - $enabled_modules = array_keys($this->container->get('extension_handler')->getEnabledModules()); + $enabled_modules = array_keys($this->container->get('extension_handler')->getModuleList()); $this->assertEqual($expected_values, $enabled_modules, format_string('@condition: extension handler returns correct results', array('@condition' => $condition))); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php index 8d4da51..2be9d12 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php @@ -82,7 +82,7 @@ public function testBasicMinimalUpgrade() { $this->assertFalse($result, 'No {menu_links} entry exists for user/autocomplete'); // Verify that all required modules are enabled. - $enabled = module_list(); + $enabled = $this->container->get('extension_handler')->getModuleList(); $required = array_filter(system_rebuild_module_data(), function ($data) { return !empty($data->info['required']); }); diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php index 24531de..ce55402 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php @@ -37,7 +37,7 @@ public function testDisabledUpgrade() { $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); // Get enabled modules. - $enabled = drupal_extension_handler()->getEnabledModules(); + $enabled = drupal_extension_handler()->getModuleList(); // Get all available modules. $available = system_rebuild_module_data(); // Filter out hidden test modules. diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php index a62eb90..48d9dce 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php @@ -242,8 +242,7 @@ protected function performUpgrade($register_errors = TRUE) { // Reload module list for modules that are enabled in the test database // but not on the test client. - system_list_reset(); - module_implements_reset(); + drupal_container()->get('extension_handler')->moduleImplementsReset(); module_load_all(FALSE, TRUE); // Rebuild the container and all caches. diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 6697c03..bb6b210 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1204,7 +1204,7 @@ function system_modules_submit($form, &$form_state) { // Gets list of modules prior to install process, unsets $form_state['storage'] // so we don't get redirected back to the confirmation form. - $pre_install_list = drupal_extension_handler()->getEnabledModules(); + $pre_install_list = drupal_extension_handler()->getModuleList(); unset($form_state['storage']); // Reverse the 'enable' list, to order dependencies before dependents. @@ -1216,7 +1216,7 @@ function system_modules_submit($form, &$form_state) { // Gets module list after install process, flushes caches and displays a // message if there are changes. - $post_install_list = drupal_extension_handler()->getEnabledModules(); + $post_install_list = drupal_extension_handler()->getModuleList(); if ($pre_install_list != $post_install_list) { drupal_flush_all_caches(); drupal_set_message(t('The configuration options have been saved.')); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index f230db6..0d70bb4 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -400,7 +400,7 @@ function system_requirements($phase) { ); // Check installed modules. - foreach (drupal_extension_handler()->getEnabledModules() as $module => $filename) { + foreach (drupal_extension_handler()->getModuleList() as $module => $filename) { $updates = drupal_get_schema_versions($module); if ($updates !== FALSE) { $default = drupal_get_installed_schema_version($module); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 58af2e7..761ded5 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -2696,7 +2696,7 @@ function system_get_info($type, $name = NULL) { $info = array(); if ($type == 'module') { $data = system_rebuild_module_data(); - foreach (drupal_extension_handler()->getEnabledModules() as $module => $filename) { + foreach (drupal_extension_handler()->getModuleList() as $module => $filename) { $info[$module] = $data[$module]->info; } } diff --git a/core/scripts/dump-database-d6.sh b/core/scripts/dump-database-d6.sh index 0b0a12b..dd9eb09 100644 --- a/core/scripts/dump-database-d6.sh +++ b/core/scripts/dump-database-d6.sh @@ -44,7 +44,7 @@ ENDOFHEADER; -foreach (drupal_extension_handler()->getEnabledModules() as $module => $filename) { +foreach (drupal_extension_handler()->getModuleList() as $module => $filename) { $output .= " * - $module\n"; } $output .= " */\n\n"; diff --git a/core/scripts/dump-database-d7.sh b/core/scripts/dump-database-d7.sh index 77edc0d..9995fe8 100644 --- a/core/scripts/dump-database-d7.sh +++ b/core/scripts/dump-database-d7.sh @@ -45,7 +45,7 @@ ENDOFHEADER; -foreach (drupal_extension_handler()->getEnabledModules() as $module => $filename) { +foreach (drupal_extension_handler()->getModuleList() as $module => $filename) { $output .= " * - $module\n"; } $output .= " */\n\n"; diff --git a/core/update.php b/core/update.php index aa25a8e..df4cd1a 100644 --- a/core/update.php +++ b/core/update.php @@ -435,7 +435,7 @@ function update_check_requirements($skip_warnings = FALSE) { // Load module basics. include_once DRUPAL_ROOT . '/core/includes/module.inc'; - $module_list['system']['filename'] = 'core/modules/system/system.module'; + $module_list['system'] = 'core/modules/system/system.module'; $extension_handler = drupal_extension_handler(); $extension_handler->setModuleList($module_list); $extension_handler->load('system');