diff -u b/core/includes/module.inc b/core/includes/module.inc --- b/core/includes/module.inc +++ b/core/includes/module.inc @@ -15,25 +15,16 @@ * Whether to load only the reduced set of modules loaded in "bootstrap mode" * for cached pages. See bootstrap.inc. Pass NULL to only check the current * status without loading of modules. - * @param bool $reset - * (optional) Internal use only. Whether to reset the internal statically - * cached flag of whether modules have been loaded. If TRUE, all modules are - * (re)loaded in the same call. Used by the testing framework to override and - * persist a limited module list for the duration of a unit test (in which no - * module system exists). * * @return bool * A Boolean indicating whether all modules have been loaded. This means all * modules; the load status of bootstrap modules cannot be checked. */ -function module_load_all($bootstrap = FALSE, $reset = FALSE) { +function module_load_all($bootstrap = FALSE) { static $has_run = FALSE; - if ($reset) { - $has_run = !$bootstrap; - } // Unless $boostrap is NULL, load the requested set of modules. - elseif (isset($bootstrap) && !$has_run) { + if (isset($bootstrap) && !$has_run) { $type = $bootstrap ? 'bootstrap' : 'module_enabled'; foreach (module_list($type) as $module) { drupal_load('module', $module); @@ -165,6 +156,9 @@ $lists = $cached->data; } else { + if (_system_list_rebuild(TRUE) && $type == 'module_enabled') { + return drupal_map_assoc(array_keys(config('system.module')->get())); + } $lists = _system_list_rebuild(); $lists['bootstrap'] = array_keys($lists['bootstrap']); } @@ -179,7 +173,13 @@ /** * Rebuild the system list data structure. */ -function _system_list_rebuild() { +function _system_list_rebuild($test_only = FALSE) { + static $in_rebuild = FALSE; + + if ($test_only) { + return $in_rebuild; + } + $in_rebuild = TRUE; // The module name (rather than the filename) is used as the fallback // weighting in order to guarantee consistent behavior across different // Drupal installations, which might have modules installed in different @@ -237,7 +237,7 @@ $lists['theme'][$key]->prefix = ($lists['theme'][$key]->info['engine'] == 'theme') ? $base_key : $lists['theme'][$key]->info['engine']; } - foreach ($enabled_modules as $name => $weight) { + foreach ($enabled_modules as $name => $weight) { // Build a list of all enabled modules. $lists['module_enabled'][$name] = $name; $filename = $module_data[$name]->filename; @@ -256,6 +256,7 @@ } cache('bootstrap')->set('system_list', $lists); cache('bootstrap')->set('bootstrap_modules', $lists['bootstrap']); + $in_rebuild = FALSE; return $lists; } diff -u b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php --- b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -829,7 +829,6 @@ // Reset module list and module load status. module_list_reset(); - module_load_all(FALSE, TRUE); // Restore original in-memory configuration. $conf = $this->originalConf; diff -u b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php --- b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php @@ -243,7 +243,6 @@ // but not on the test client. system_list_reset(); module_implements_reset(); - module_load_all(FALSE, TRUE); // Rebuild caches. drupal_flush_all_caches();