Commit c76655c9 authored by Dries's avatar Dries

- Patch #794936 by c960657, amateescu: system_rebuild_module_data() called...

- Patch #794936 by c960657, amateescu: system_rebuild_module_data() called twice on admin/build/modules.
parent b7459d8e
......@@ -193,6 +193,7 @@ function system_list($type) {
*/
function system_list_reset() {
drupal_static_reset('system_list');
drupal_static_reset('system_rebuild_module_data');
drupal_static_reset('list_themes');
cache_clear_all('bootstrap_modules', 'cache_bootstrap');
cache_clear_all('system_list', 'cache_bootstrap');
......
......@@ -127,6 +127,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
// First, create a fake missing dependency. Forum depends on poll, which
// depends on a made-up module, foo. Nothing should be installed.
variable_set('dependency_test', 'missing dependency');
drupal_static_reset('system_rebuild_module_data');
$result = module_enable(array('forum'));
$this->assertFalse($result, t('module_enable() returns FALSE if dependencies are missing.'));
$this->assertFalse(module_exists('forum'), t('module_enable() aborts if dependencies are missing.'));
......@@ -134,6 +135,7 @@ class ModuleUnitTest extends DrupalWebTestCase {
// Now, fix the missing dependency. Forum module depends on poll, but poll
// depends on the PHP module. module_enable() should work.
variable_set('dependency_test', 'dependency');
drupal_static_reset('system_rebuild_module_data');
$result = module_enable(array('forum'));
$this->assertTrue($result, t('module_enable() returns the correct value.'));
// Verify that the fake dependency chain was installed.
......
......@@ -2361,12 +2361,19 @@ function _system_rebuild_module_data() {
* Array of all available modules and their data.
*/
function system_rebuild_module_data() {
$modules = _system_rebuild_module_data();
ksort($modules);
system_get_files_database($modules, 'module');
system_update_files_database($modules, 'module');
$modules = _module_build_dependencies($modules);
return $modules;
$modules_cache = &drupal_static(__FUNCTION__);
// Only rebuild once per request. $modules and $modules_cache cannot be
// combined into one variable, because the $modules_cache variable is reset by
// reference from system_list_reset() during the rebuild.
if (!isset($modules_cache)) {
$modules = _system_rebuild_module_data();
ksort($modules);
system_get_files_database($modules, 'module');
system_update_files_database($modules, 'module');
$modules = _module_build_dependencies($modules);
$modules_cache = $modules;
}
return $modules_cache;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment