diff -u b/core/includes/install.core.inc b/core/includes/install.core.inc --- b/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1448,7 +1448,7 @@ function install_bootstrap_full(&$install_state) { // Clear the module list that was overriden earlier in the process. // This will allow all freshly installed modules to be loaded. - drupal_static_reset('module_list'); + module_list_reset(); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); } diff -u b/core/includes/module.inc b/core/includes/module.inc --- b/core/includes/module.inc +++ b/core/includes/module.inc @@ -45,54 +45,64 @@ * * Acts as a wrapper around system_list(), returning either a list of all * enabled modules, or just modules needed for bootstrap. - * An optional parameter allows an alternative module list to be provided, - * which is then stored and used in subsequent calls instead of the one - * provided by system_list(). * - * @param $type + * The returned module list is always based on system_list(). The only exception + * to that is when a fixed list of modules has been passed in previously, in + * which case system_list() is omitted and the fixed list is always returned in + * subsequent calls until manually reverted via module_list_reset(). + * + * @param string $type * The type of list to return: * - module_enabled: All enabled modules. * - bootstrap: All enabled modules required for bootstrap. - * @param $fixed_list - * (optional) If an array of module names is provided, this will override the - * module list with the given set of modules. This will persist until the next - * call with a new $fixed_list passed in. This parameter is primarily - * intended for internal use (e.g., in install.php and update.php). + * @param array $fixed_list + * (optional) An array of module names to override the list of modules. This + * list will persist until the next call with a new $fixed_list passed in. + * Primarily intended for internal use (e.g., in install.php and update.php). + * Use module_list_reset() to undo the $fixed_list override. * - * @return + * @return array * An associative array whose keys and values are the names of the modules in * the list. */ -function module_list($type = 'module_enabled', $fixed_list = NULL) { - // Tracks data acquired from $fixed_list. +function module_list($type = 'module_enabled', array $fixed_list = NULL) { + // This static is only used for $fixed_list. $module_list = &drupal_static(__FUNCTION__); // The list that will be be returned. Separate from $module_list in order - // to avoid statically caching data acquired from system_list(), since - // that function already has its own static cache. + // to not duplicate the static cache of system_list(). $list = $module_list; if (isset($fixed_list)) { foreach ($fixed_list as $name => $module) { drupal_get_filename('module', $name, $module['filename']); $module_list[$name] = $name; - } + } $list = $module_list; } elseif (!isset($module_list)) { - if ($type == 'bootstrap') { - $list = system_list('bootstrap'); - } - else { - // Not using drupal_map_assoc() here as that requires common.inc. - $list = array_keys(system_list($type)); - $list = (!empty($list) ? array_combine($list, $list) : array()); + if ($type == 'bootstrap') { + $list = system_list('bootstrap'); + } + else { + // Not using drupal_map_assoc() here as that requires common.inc. + $list = array_keys(system_list($type)); + $list = (!empty($list) ? array_combine($list, $list) : array()); } } return $list; } /** + * Reverts an enforced fixed list of module_list(). + * + * Subsequent calls to module_list() will no longer use a fixed list. + */ +function module_list_reset() { + drupal_static_reset('module_list'); +} + +/** * Build a list of bootstrap modules and enabled modules and themes. * * @param $type @@ -660,8 +670,7 @@ $implementations['#write_cache'] = TRUE; $hook_info = module_hook_info(); $implementations[$hook] = array(); - $list = module_list(); - foreach ($list as $module) { + foreach (module_list() as $module) { $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']); // Since module_hook() may needlessly try to load the include file again, // function_exists() is used directly here. reverted: --- b/core/modules/search/lib/Drupal/search/Tests/SearchExcerptTest.php +++ a/core/modules/search/lib/Drupal/search/Tests/SearchExcerptTest.php @@ -7,12 +7,12 @@ namespace Drupal\search\Tests; +use Drupal\simpletest\UnitTestBase; -use Drupal\simpletest\WebTestBase; /** * Tests the search_excerpt() function. */ +class SearchExcerptTest extends UnitTestBase { -class SearchExcerptTest extends WebTestBase { public static function getInfo() { return array( 'name' => 'Search excerpt extraction', @@ -21,6 +21,11 @@ ); } + function setUp() { + drupal_load('module', 'search'); + parent::setUp(); + } + /** * Tests search_excerpt() with several simulated search keywords. * diff -u b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php --- b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -776,7 +776,8 @@ // Reload module list and implementations to ensure that test module hooks // aren't called after tests. - drupal_static_reset('module_list'); + drupal_static_reset('system_list'); + module_list_reset(); module_implements_reset(); // Reset the Field API. reverted: --- b/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php +++ /dev/null @@ -1,48 +0,0 @@ - 'Module class loader', - 'description' => 'Tests class loading for modules.', - 'group' => 'Module', - ); - } - - /** - * Tests that module-provided classes can be loaded when a module is enabled. - */ - function testClassLoading() { - $expected = 'Drupal\\module_autoload_test\\SomeClass::testMethod() was invoked.'; - - module_enable(array('module_test', 'module_autoload_test'), FALSE); - $this->resetAll(); - // Check twice to test an unprimed and primed system_list() cache. - for ($i=0; $i<2; $i++) { - $this->drupalGet('module-test/class-loading'); - $this->assertText($expected, t('Autoloader loads classes from an enabled module.')); - } - - module_disable(array('module_autoload_test'), FALSE); - $this->resetAll(); - // Check twice to test an unprimed and primed system_list() cache. - for ($i=0; $i<2; $i++) { - $this->drupalGet('module-test/class-loading'); - $this->assertNoText($expected, t('Autoloader does not load classes from a disabled module.')); - } - } -} reverted: --- b/core/modules/system/lib/Drupal/system/Tests/Module/InstallTest.php +++ /dev/null @@ -1,47 +0,0 @@ - 'Module installation', - 'description' => 'Tests the installation of modules.', - 'group' => 'Module', - ); - } - - function setUp() { - parent::setUp('module_test'); - } - - /** - * Test that calls to drupal_write_record() work during module installation. - * - * This is a useful function to test because modules often use it to insert - * initial data in their database tables when they are being installed or - * enabled. Furthermore, drupal_write_record() relies on the module schema - * information being available, so this also checks that the data from one of - * the module's hook implementations, in particular hook_schema(), is - * properly available during this time. Therefore, this test helps ensure - * that modules are fully functional while Drupal is installing and enabling - * them. - */ - function testDrupalWriteRecord() { - // Check for data that was inserted using drupal_write_record() while the - // 'module_test' module was being installed and enabled. - $data = db_query("SELECT data FROM {module_test}")->fetchCol(); - $this->assertTrue(in_array('Data inserted in hook_install()', $data), t('Data inserted using drupal_write_record() in hook_install() is correctly saved.')); - $this->assertTrue(in_array('Data inserted in hook_enable()', $data), t('Data inserted using drupal_write_record() in hook_enable() is correctly saved.')); - } -} reverted: --- b/core/modules/system/lib/Drupal/system/Tests/Module/UninstallTest.php +++ /dev/null @@ -1,41 +0,0 @@ - 'Module uninstallation', - 'description' => 'Tests the uninstallation of modules.', - 'group' => 'Module', - ); - } - - function setUp() { - parent::setUp('module_test', 'user'); - } - - /** - * Tests the hook_modules_uninstalled() of the user module. - */ - function testUserPermsUninstalled() { - // Uninstalls the module_test module, so hook_modules_uninstalled() - // is executed. - module_disable(array('module_test')); - drupal_uninstall_modules(array('module_test')); - - // Are the perms defined by module_test removed from {role_permission}. - $count = db_query("SELECT COUNT(rid) FROM {role_permission} WHERE permission = :perm", array(':perm' => 'module_test perm'))->fetchField(); - $this->assertEqual(0, $count, t('Permissions were all removed.')); - } -} diff -u b/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc --- b/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1198,7 +1198,6 @@ // Gets module list after install process, flushes caches and displays a // message if there are changes. - drupal_static_reset('system_list'); $post_install_list = module_list(); if ($pre_install_list != $post_install_list) { drupal_flush_all_caches(); diff -u b/core/modules/system/system.install b/core/modules/system/system.install --- b/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -514,6 +514,7 @@ // Clear out module list and hook implementation statics before calling // system_rebuild_theme_data(). drupal_static_reset('system_list'); + module_list_reset(); module_implements_reset(); // Load system theme data appropriately. reverted: --- b/core/modules/system/tests/module.test +++ a/core/modules/system/tests/module.test @@ -53,7 +53,7 @@ ->condition('type', 'module') ->execute(); // Reset the module list. + module_list(TRUE); - system_list_reset(); // Move contact to the end of the array. unset($module_list[array_search('contact', $module_list)]); $module_list[] = 'contact'; @@ -64,12 +64,12 @@ 'system' => array('filename' => drupal_get_path('module', 'system')), 'menu' => array('filename' => drupal_get_path('module', 'menu')), ); + module_list(FALSE, FALSE, FALSE, $fixed_list); - module_list(NULL, $fixed_list); $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list)); $this->assertModuleList($new_module_list, t('When using a fixed list')); // Reset the module list. + module_list(TRUE); - drupal_static_reset('module_list'); $this->assertModuleList($module_list, t('After reset')); } @@ -82,6 +82,8 @@ protected function assertModuleList(Array $expected_values, $condition) { $expected_values = array_combine($expected_values, $expected_values); $this->assertEqual($expected_values, module_list(), t('@condition: module_list() returns correct results', array('@condition' => $condition))); + ksort($expected_values); + $this->assertIdentical($expected_values, module_list(FALSE, FALSE, TRUE), t('@condition: module_list() returns correctly sorted results', array('@condition' => $condition))); } /** only in patch2: unchanged: --- a/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ClassLoaderTest.php @@ -13,8 +13,6 @@ use Drupal\simpletest\WebTestBase; * Tests class loading. */ class ClassLoaderTest extends WebTestBase { - protected $profile = 'testing'; - public static function getInfo() { return array( 'name' => 'Module class loader', only in patch2: unchanged: --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php @@ -55,7 +55,7 @@ class ModuleApiTest extends WebTestBase { ->condition('type', 'module') ->execute(); // Reset the module list. - module_list(TRUE); + system_list_reset(); // Move contact to the end of the array. unset($module_list[array_search('contact', $module_list)]); $module_list[] = 'contact'; @@ -66,12 +66,12 @@ class ModuleApiTest extends WebTestBase { 'system' => array('filename' => drupal_get_path('module', 'system')), 'menu' => array('filename' => drupal_get_path('module', 'menu')), ); - module_list(FALSE, FALSE, FALSE, $fixed_list); + module_list(NULL, $fixed_list); $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list)); $this->assertModuleList($new_module_list, t('When using a fixed list')); // Reset the module list. - module_list(TRUE); + module_list_reset(); $this->assertModuleList($module_list, t('After reset')); } @@ -84,8 +84,6 @@ class ModuleApiTest extends WebTestBase { protected function assertModuleList(Array $expected_values, $condition) { $expected_values = array_combine($expected_values, $expected_values); $this->assertEqual($expected_values, module_list(), t('@condition: module_list() returns correct results', array('@condition' => $condition))); - ksort($expected_values); - $this->assertIdentical($expected_values, module_list(FALSE, FALSE, TRUE), t('@condition: module_list() returns correctly sorted results', array('@condition' => $condition))); } /**