Commit 44d71e1e authored by Gábor Hojtsy's avatar Gábor Hojtsy

#200674 by scor, catch: update.php should inform users if their memory limit...

#200674 by scor, catch: update.php should inform users if their memory limit will possibly result in a WSOD
parent f1698657
......@@ -163,6 +163,14 @@ function theme_update_page($content, $show_messages = TRUE) {
// 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'] .= '<h4>'. $title .':</h4>';
$variables['messages'] .= theme('status_messages', 'warning');
}
return theme_render_template('themes/garland/maintenance-page.tpl.php', $variables);
}
......
......@@ -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 <a href="@url">Drupal requirements</a> 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 <a href="@admin-file-system">file system settings page</a> 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 <a href="@admin-file-system">file system settings page</a> 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 <a href="@handbook_url">on-line handbook</a>.', 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 <a href="@handbook_url">on-line handbook</a>.', 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 (<em>private</em> download method)');
}
}
$requirements['file system']['title'] = $t('File system');
// See if updates are available in update.php.
if ($phase == 'runtime') {
......
......@@ -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', '<form method="post" action="update.php?op=info"><input type="submit" value="Continue" /></form>', FALSE);
exit;
}
install_goto('update.php?op=info');
}
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_maintenance_theme();
......@@ -545,7 +606,7 @@ function update_task_list($active = NULL) {
$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
switch ($op) {
// update.php ops
case '':
case 'info':
$output = update_info_page();
break;
......
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