summaryrefslogtreecommitdiff
path: root/modules/system/system.admin.inc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-12-08 06:39:34 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-12-08 06:39:34 +0000
commitdaa59856c3642c192be43104ff945f3182d026d9 (patch)
treeb00197b7ac118255337586f3ca001b44866b1aa6 /modules/system/system.admin.inc
parentddf591963e2f1f3e8d10a230683ee180720469f2 (diff)
downloadbrdo-daa59856c3642c192be43104ff945f3182d026d9.tar.gz
brdo-daa59856c3642c192be43104ff945f3182d026d9.tar.bz2
#375352 by Damien Tournoud, sun, and chx: Fixed errors caused by adding dependency to non-existing module (with tests).
Diffstat (limited to 'modules/system/system.admin.inc')
-rw-r--r--modules/system/system.admin.inc59
1 files changed, 34 insertions, 25 deletions
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index f49c71f6f..c8c3d01b7 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -992,6 +992,15 @@ function system_modules_confirm_form($modules, $storage) {
);
$items[] = format_plural(count($info['requires']), 'You must enable the @required module to install @module.', 'You must enable the @required modules to install @module.', $t_argument);
}
+
+ foreach ($storage['missing_modules'] as $name => $info) {
+ $t_argument = array(
+ '@module' => $name,
+ '@depends' => implode(', ', $info['depends']),
+ );
+ $items[] = format_plural(count($info['depends']), 'The @module module is missing, so the following module will be disabled: @depends.', 'The @module module is missing, so the following module will be disabled: @depends.', $t_argument);
+ }
+
$form['text'] = array('#markup' => theme('item_list', array('items' => $items)));
if ($form) {
@@ -1000,7 +1009,7 @@ function system_modules_confirm_form($modules, $storage) {
$form,
t('Some required modules must be enabled'),
'admin/config/modules',
- t('Would you like to continue with enabling the above?'),
+ t('Would you like to continue with the above?'),
t('Continue'),
t('Cancel'));
return $form;
@@ -1039,6 +1048,8 @@ function system_modules_submit($form, &$form_state) {
$new_modules = array();
// Modules that need to be switched on because other modules require them.
$more_modules = array();
+ $missing_modules = array();
+
// Go through each module, finding out if we should enable, install, or
// disable it. Also, we find out if there are modules it requires that are
// not enabled.
@@ -1052,18 +1063,26 @@ function system_modules_submit($form, &$form_state) {
elseif (!module_exists($name)) {
$modules_to_be_enabled[$name] = $name;
}
+
// If we're not coming from a confirmation form, search for modules the
// new ones require and see whether there are any that additionally
// need to be switched on.
if (empty($form_state['storage'])) {
foreach ($form['modules'][$module['group']][$name]['#requires'] as $requires => $v) {
- if (!$modules[$requires]['enabled']) {
- if (!isset($more_modules[$name])) {
- $more_modules[$name]['name'] = $files[$name]->info['name'];
+ if (!isset($files[$requires])) {
+ // The required module is missing, mark this module as disabled.
+ $missing_modules[$requires]['depends'][] = $name;
+ $modules[$name]['enabled'] = FALSE;
+ }
+ else {
+ if (!$modules[$requires]['enabled']) {
+ if (!isset($more_modules[$name])) {
+ $more_modules[$name]['name'] = $files[$name]->info['name'];
+ }
+ $more_modules[$name]['requires'][$requires] = $files[$requires]->info['name'];
}
- $more_modules[$name]['requires'][$requires] = $files[$requires]->info['name'];
+ $modules[$requires] = array('group' => $files[$requires]->info['package'], 'enabled' => TRUE);
}
- $modules[$requires] = array('group' => $files[$requires]->info['package'], 'enabled' => TRUE);
}
}
}
@@ -1075,28 +1094,18 @@ function system_modules_submit($form, &$form_state) {
$disable_modules[$name] = $name;
}
}
- if ($more_modules) {
+
+ if ($more_modules || $missing_modules) {
// If we need to switch on more modules because other modules require
// them and they haven't confirmed, don't process the submission yet. Store
// the form submission data needed later.
- if (!isset($form_state['values']['confirm'])) {
- $form_state['storage'] = array('more_modules' => $more_modules, 'modules' => $modules);
- $form_state['rebuild'] = TRUE;
- return;
- }
- // Otherwise, install or enable the modules.
- else {
- foreach ($form_state['storage']['more_modules'] as $info) {
- foreach ($info['requires'] as $requires => $name) {
- if (drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
- $new_modules[$name] = $name;
- }
- else {
- $modules_to_be_enabled[$name] = $name;
- }
- }
- }
- }
+ $form_state['storage'] = array(
+ 'more_modules' => $more_modules,
+ 'missing_modules' => $missing_modules,
+ 'modules' => $modules
+ );
+ $form_state['rebuild'] = TRUE;
+ return;
}
$old_module_list = module_list();