Commit 437a4982 authored by drumm's avatar drumm

#97271 by Jaza. Ensure that hooks are not invoked for newly-disabled modules.

parent 706a462c
......@@ -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);
......
......@@ -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.');
}
......
......@@ -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();
......
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