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 /includes/module.inc | |
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.
Diffstat (limited to 'includes/module.inc')
-rw-r--r-- | includes/module.inc | 41 |
1 files changed, 29 insertions, 12 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); |