diff options
author | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-11-27 23:15:41 +0000 |
---|---|---|
committer | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-11-27 23:15:41 +0000 |
commit | 437a49829500ce1847159035099d91be3e775244 (patch) | |
tree | 8dd9cdf2ce1b9a080633dbe1d0252c0171aa6049 | |
parent | 706a462c892c42917cd6cbb0640000a4b813f519 (diff) | |
download | brdo-437a49829500ce1847159035099d91be3e775244.tar.gz brdo-437a49829500ce1847159035099d91be3e775244.tar.bz2 |
#97271 by Jaza. Ensure that hooks are not invoked for newly-disabled modules.
-rw-r--r-- | includes/module.inc | 41 | ||||
-rw-r--r-- | modules/system/system.install | 2 | ||||
-rw-r--r-- | modules/system/system.module | 6 |
3 files changed, 35 insertions, 14 deletions
diff --git a/includes/module.inc b/includes/module.inc index fde36f2f9..3df6d264e 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -261,20 +261,28 @@ function module_enable($module_list) { } /** - * Disable a given module and call its disable hook. + * Disable a given set of modules. * - * @param $module - * The name of the module (without the .module extension). + * @param $module_list + * An array of module names. */ -function module_disable($module) { - if (module_exists($module)) { - module_load_install($module); - module_invoke($module, 'disable'); - db_query("UPDATE {system} SET status = 0, throttle = 0 WHERE type = 'module' AND name = '%s'", $module); - return TRUE; +function module_disable($module_list) { + $invoke_modules = array(); + foreach ($module_list as $module) { + if (module_exists($module)) { + module_load_install($module); + module_invoke($module, 'disable'); + db_query("UPDATE {system} SET status = 0, throttle = 0 WHERE type = 'module' AND name = '%s'", $module); + $invoke_modules[] = $module; + } } - else { - return FALSE; + + if (!empty($invoke_modules)) { + // Refresh the module list to exclude the disabled modules. + module_list(TRUE, FALSE); + // Force to regenerate the stored list of hook implementations. + module_implements('', FALSE, TRUE); + cache_clear_all('*', 'cache_menu', TRUE); } } @@ -322,12 +330,21 @@ function module_hook($module, $hook) { * @param $sort * By default, modules are ordered by weight and filename, settings this option * to TRUE, module list will be ordered by module name. + * @param $refresh + * For internal use only: Whether to force the stored list of hook + * implementations to be regenerated (such as after enabling a new module, + * before processing hook_enable). * @return * An array with the names of the modules which are implementing this hook. */ -function module_implements($hook, $sort = FALSE) { +function module_implements($hook, $sort = FALSE, $refresh = FALSE) { static $implementations; + if ($refresh) { + unset($implementations); + return; + } + if (!isset($implementations[$hook])) { $implementations[$hook] = array(); $list = module_list(FALSE, TRUE, $sort); diff --git a/modules/system/system.install b/modules/system/system.install index 9bb327b5e..7444b4893 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -3329,7 +3329,7 @@ function system_update_1010() { // Disable urlfilter.module, if it exists. if (module_exists('urlfilter')) { - module_disable('urlfilter'); + module_disable(array('urlfilter')); $ret[] = update_sql("UPDATE {filter_formats} SET module = 'filter', delta = 3 WHERE module = 'urlfilter'"); $ret[] = t('URL Filter module was disabled; this functionality has now been added to core.'); } diff --git a/modules/system/system.module b/modules/system/system.module index d4d2df881..be8127273 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1435,6 +1435,7 @@ function system_modules_submit($form_id, $form_values) { } $enable_modules = array(); + $disable_modules = array(); foreach ($form_values['status'] as $key => $choice) { if ($choice) { if (drupal_get_installed_schema_version($key) == SCHEMA_UNINSTALLED) { @@ -1445,13 +1446,16 @@ function system_modules_submit($form_id, $form_values) { } } else { - module_disable($key); + $disable_modules[] = $key; } } if (!empty($enable_modules)) { module_enable($enable_modules); } + if (!empty($disable_modules)) { + module_disable($disable_modules); + } $old_module_list = module_list(); |