diff --git a/core/includes/module.inc b/core/includes/module.inc index db1947d..a772436 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -11,30 +11,26 @@ /** * Loads all the modules that have been enabled in the system table. * - * @param bool $bootstrap + * @param $bootstrap * 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). + * for cached pages. See bootstrap.inc. * - * @return bool - * A Boolean indicating whether all modules have been loaded. This means all - * modules; the load status of bootstrap modules cannot be checked. + * @return + * If $bootstrap is NULL, return a boolean indicating whether all modules + * have been loaded. */ -function module_load_all($bootstrap = FALSE, $reset = FALSE) { - static $has_run = FALSE; - - if ($reset) { - $has_run = FALSE; +function module_load_all($bootstrap = FALSE) { + // Already loaded code cannot be unloaded, but new modules may be added within + // a request, which should be loaded as well. + // Use the advanced drupal_static() pattern, since this is called very often. + // @see theme() + static $drupal_static_fast; + if (!isset($drupal_static_fast)) { + $drupal_static_fast['has_run'] = &drupal_static(__FUNCTION__, FALSE); } + $has_run = &$drupal_static_fast['has_run']; - // Unless $boostrap is NULL, load the requested set of modules. - if (isset($bootstrap) && !$has_run) { + if (isset($bootstrap)) { $type = $bootstrap ? 'bootstrap' : 'module_enabled'; foreach (module_list($type) as $module) { drupal_load('module', $module); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 048da36..00eb07f 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -796,9 +796,8 @@ protected function tearDown() { // Reset all static variables. drupal_static_reset(); - // Reset module list and module load status. + // Reset module list. module_list_reset(); - module_load_all(FALSE, TRUE); // Restore original in-memory configuration. $conf = $this->originalConf;