diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-06-28 03:56:43 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-06-28 03:56:43 +0000 |
commit | 4dafb3953cabb0911286e6d683b495f6e1c43238 (patch) | |
tree | 6ada357091da9b02add4c17a25018ab4c11e48bb /includes/module.inc | |
parent | 783d5411797cbbbb67060f3bf6484860fae71782 (diff) | |
download | brdo-4dafb3953cabb0911286e6d683b495f6e1c43238.tar.gz brdo-4dafb3953cabb0911286e6d683b495f6e1c43238.tar.bz2 |
#482346 by Berdir: Move module installation logic to module_enable() to prevent errors upon enabling modules.
Diffstat (limited to 'includes/module.inc')
-rw-r--r-- | includes/module.inc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/includes/module.inc b/includes/module.inc index a8a878cb6..ce8470962 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -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) { |