Commit 4dafb395 authored by webchick's avatar webchick

#482346 by Berdir: Move module installation logic to module_enable() to...

#482346 by Berdir: Move module installation logic to module_enable() to prevent errors upon enabling modules.
parent 783d5411
......@@ -516,11 +516,7 @@ function drupal_install_modules($module_list = array(), $disable_modules_install
} while ($moved);
asort($module_list);
$module_list = array_keys($module_list);
$modules_installed = array_filter($module_list, '_drupal_install_module');
if (!$disable_modules_installed_hook && !empty($modules_installed)) {
module_invoke_all('modules_installed', $modules_installed);
}
module_enable($module_list);
module_enable($module_list, $disable_modules_installed_hook);
}
/**
......
......@@ -177,9 +177,15 @@ function module_load_all_includes($type, $name = NULL) {
*
* @param $module_list
* An array of module names.
* @param $disable_modules_installed_hook
* Normally just testing wants to set this to TRUE.
*/
function module_enable($module_list) {
function module_enable($module_list, $disable_modules_installed_hook = FALSE) {
$invoke_modules = array();
// Try to install the enabled modules and collect which were installed.
// $module_list is not changed and already installed modules are ignored.
$modules_installed = array_filter($module_list, '_drupal_install_module');
foreach ($module_list as $module) {
$existing = db_query("SELECT status FROM {system} WHERE type = :type AND name = :name", array(
':type' => 'module',
......@@ -203,6 +209,11 @@ function module_enable($module_list) {
module_list(TRUE);
// Force to regenerate the stored list of hook implementations.
registry_rebuild();
// If any modules were newly installed, execute the hook for them.
if (!$disable_modules_installed_hook && !empty($modules_installed)) {
module_invoke_all('modules_installed', $modules_installed);
}
}
foreach ($invoke_modules as $module) {
......
......@@ -634,3 +634,11 @@ function node_multiple_delete_confirm_submit($form, &$form_state) {
$form_state['redirect'] = 'admin/content/node';
return;
}
/**
* Implement hook_modules_installed()
*/
function node_modules_installed($modules) {
// Clear node type cache for node permissions.
node_type_clear();
}
\ No newline at end of file
......@@ -113,6 +113,7 @@ class EnableDisableTestCase extends ModuleTestCase {
// Install (and enable) aggregator module.
$edit = array();
$edit['modules[Core][aggregator][enable]'] = 'aggregator';
$edit['modules[Core][forum][enable]'] = 'forum';
$this->drupalPost('admin/build/modules', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
......
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