Index: update.php =================================================================== RCS file: /cvs/drupal/drupal/update.php,v retrieving revision 1.247 diff -u -p -r1.247 update.php --- update.php 7 Jan 2008 19:43:28 -0000 1.247 +++ update.php 15 Jan 2008 16:09:46 -0000 @@ -515,11 +515,72 @@ function update_task_list($active = NULL drupal_set_content('left', theme('task_list', $tasks, $active)); } +/** + * Check update requirements and report any errors. + */ +function update_check_requirements() { + // Check the system module requirements only. + $requirements = module_invoke('system', 'requirements', 'update'); + $severity = drupal_requirements_severity($requirements); + + // If there are issues, report them. + if ($severity != REQUIREMENT_OK) { + foreach ($requirements as $requirement) { + if (isset($requirement['severity']) && $requirement['severity'] != REQUIREMENT_OK) { + $message = isset($requirement['description']) ? $requirement['description'] : ''; + if (isset($requirement['value']) && $requirement['value']) { + $message .= ' (Currently using '. $requirement['title'] .' '. $requirement['value'] .')'; + } + drupal_set_message($message, 'warning'); + } + } + } +} + // Some unavoidable errors happen because the database is not yet up-to-date. // Our custom error handler is not yet installed, so we just suppress them. ini_set('display_errors', FALSE); -include_once './includes/bootstrap.inc'; +require_once './includes/bootstrap.inc'; + +// We only load DRUPAL_BOOTSTRAP_CONFIGURATION for the update requirements +// check to avoid reaching the PHP memory limit. +$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : ''; +if (empty($op)) { + // Minimum load of components. + drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); + + require_once './includes/install.inc'; + require_once './includes/file.inc'; + require_once './modules/system/system.install'; + + // Load module basics. + include_once './includes/module.inc'; + $module_list['system']['filename'] = 'modules/system/system.module'; + $module_list['filter']['filename'] = 'modules/filter/filter.module'; + module_list(TRUE, FALSE, FALSE, $module_list); + drupal_load('module', 'system'); + drupal_load('module', 'filter'); + + // Set up $language, since the installer components require it. + drupal_init_language(); + + // Set up theme system for the maintenance page. + drupal_maintenance_theme(); + + // Check the update requirements for Drupal. + update_check_requirements(); + + // Display the warning messages (if any) in a dedicated maintenance page, + // or redirect to the update information page if no message. + $messages = drupal_set_message(); + if (!empty($messages['warning'])) { + drupal_maintenance_theme(); + print theme('update_page', '
', FALSE); + exit; + } + install_goto('update.php?op=info'); +} drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_maintenance_theme(); @@ -545,7 +606,7 @@ if (!empty($update_free_access) || $user $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : ''; switch ($op) { // update.php ops - case '': + case 'info': $output = update_info_page(); break; Index: includes/theme.maintenance.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.maintenance.inc,v retrieving revision 1.7 diff -u -p -r1.7 theme.maintenance.inc --- includes/theme.maintenance.inc 7 Jan 2008 15:31:50 -0000 1.7 +++ includes/theme.maintenance.inc 15 Jan 2008 16:09:46 -0000 @@ -163,6 +163,14 @@ function theme_update_page($content, $sh // The maintenance preprocess function is recycled here. template_preprocess_maintenance_page($variables); + // Special handling of warning messages. + $messages = drupal_set_message(); + if (isset($messages['warning'])) { + $title = count($messages['warning']) > 1 ? 'The following update warnings should be carefully reviewed before continuing' : 'The following update warning should be carefully reviewed before continuing'; + $variables['messages'] .= '

'. $title .':

'; + $variables['messages'] .= theme('status_messages', 'warning'); + } + return theme_render_template('themes/garland/maintenance-page.tpl.php', $variables); } Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.229 diff -u -p -r1.229 system.install --- modules/system/system.install 10 Jan 2008 22:47:17 -0000 1.229 +++ modules/system/system.install 15 Jan 2008 16:09:46 -0000 @@ -78,11 +78,12 @@ function system_requirements($phase) { $description = ''; if ($phase == 'install') { $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)); - $requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING; + } + elseif ($phase == 'update') { + $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)); } elseif ($phase == 'runtime') { $description = $t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)); - $requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING; } if (!empty($description)) { @@ -94,6 +95,7 @@ function system_requirements($phase) { } $requirements['php_memory_limit']['description'] = $description .' '. $t('See the Drupal requirements for more information.', array('@url' => 'http://drupal.org/requirements')); + $requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING; } } @@ -185,6 +187,9 @@ function system_requirements($phase) { // Test files directory $directory = file_directory_path(); + $requirements['file system'] = array( + 'title' => $t('File system'), + ); // For installer, create the directory if possible. if ($phase == 'install' && !is_dir($directory) && @mkdir($directory)) { @@ -194,25 +199,28 @@ function system_requirements($phase) { $is_writable = is_writable($directory); $is_directory = is_dir($directory); if (!$is_writable || !$is_directory) { + $description = ''; + $requirements['file system']['value'] = $t('Not writable'); if (!$is_directory) { $error = $t('The directory %directory does not exist.', array('%directory' => $directory)); } else { $error = $t('The directory %directory is not writable.', array('%directory' => $directory)); } - $requirements['file system'] = array( - 'value' => $t('Not writable'), - 'severity' => REQUIREMENT_ERROR, - ); + // The files directory requirement check is done only during install and runtime. if ($phase == 'runtime') { - $requirements['file system']['description'] = $error .' '. $t('You may need to set the correct directory at the file system settings page or change the current directory\'s permissions so that it is writable.', array('@admin-file-system' => url('admin/settings/file-system'))); + $description = $error .' '. $t('You may need to set the correct directory at the file system settings page or change the current directory\'s permissions so that it is writable.', array('@admin-file-system' => url('admin/settings/file-system'))); } - else if ($phase == 'install') { + elseif ($phase == 'install') { // For the installer UI, we need different wording. 'value' will // be treated as version, so provide none there. - $requirements['file system']['description'] = $error .' '. $t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually, or ensure that the installer has the permissions to create it automatically. For more information, please see INSTALL.txt or the on-line handbook.', array('@handbook_url' => 'http://drupal.org/server-permissions')); + $description = $error .' '. $t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually, or ensure that the installer has the permissions to create it automatically. For more information, please see INSTALL.txt or the on-line handbook.', array('@handbook_url' => 'http://drupal.org/server-permissions')); $requirements['file system']['value'] = ''; } + if (!empty($description)) { + $requirements['file system']['description'] = $description; + $requirements['file system']['severity'] = REQUIREMENT_ERROR; + } } else { if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) { @@ -222,7 +230,6 @@ function system_requirements($phase) { $requirements['file system']['value'] = $t('Writable (private download method)'); } } - $requirements['file system']['title'] = $t('File system'); // See if updates are available in update.php. if ($phase == 'runtime') {