From ba0ff1a9b7805cde4521d07ca0f039506173bb6b Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Fri, 2 Mar 2007 09:40:27 +0000 Subject: #117018: Use Garland theme for installer/maintenance pages, and add task list in the sidebar. - Refactor partial-page handling for the maintenance page. It's an exotic quirk for update.php and belongs there. --- update.php | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) (limited to 'update.php') diff --git a/update.php b/update.php index fb07f0458..d26c96f14 100644 --- a/update.php +++ b/update.php @@ -325,6 +325,8 @@ function update_selection_page() { drupal_add_js('misc/update.js', 'core', 'header', FALSE, TRUE); $output .= drupal_get_form('update_script_selection_form'); + update_task_list('select'); + return $output; } @@ -475,28 +477,41 @@ function update_do_update_page() { */ function update_progress_page_nojs() { drupal_set_title('Updating'); + update_task_list('run'); $new_op = 'do_update_nojs'; - if ($_SERVER['REQUEST_METHOD'] == 'GET') { - // Error handling: if PHP dies, it will output whatever is in the output - // buffer, followed by the error message. + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + // This is the first page so return some output immediately. + $percentage = 0; + $message = 'Starting updates'; + } + else { + // This is one of the later requests: do some updates first. + + // Error handling: if PHP dies due to a fatal error (e.g. non-existant + // function), it will output whatever is in the output buffer, + // followed by the error message. So, we put an explanation in the + // buffer to guide the user when an error happens. ob_start(); $fallback = '

An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference. Please continue to the update summary.

'; - print theme('maintenance_page', $fallback, FALSE, TRUE); + $fallback = theme('maintenance_page', $fallback, FALSE); + + // We strip the end of the page using a marker in the template, so any + // additional HTML output by PHP shows up inside the page rather than + // below it. While this causes invalid HTML, the same would be true if + // we didn't, as content is not allowed to appear after anyway. + list($fallback) = explode('', $fallback); + print $fallback; + // Do updates list($percentage, $message) = update_do_updates(); if ($percentage == 100) { $new_op = 'finished'; } - // Updates successful; remove fallback + // Updates were successful; wipe the output buffer as it's unneeded. ob_end_clean(); } - else { - // This is the first page so return some output immediately. - $percentage = 0; - $message = 'Starting updates'; - } drupal_set_html_head(''); $output = theme('progress_bar', $percentage, $message); @@ -513,6 +528,7 @@ function update_finished_page($success) { $links[] = 'main page'; $links[] = 'administration pages'; + update_task_list(); // Report end result if ($success) { $output = '

Updates were attempted. If you see no failures below, you may proceed happily to the administration pages. Otherwise, you may need to update your database manually. All errors have been logged.

'; @@ -559,6 +575,7 @@ function update_finished_page($success) { } function update_info_page() { + update_task_list('info'); drupal_set_title('Drupal database update'); $output = "
    \n"; $output .= "
  1. Use this script to upgrade an existing Drupal installation. You don't need this script when installing Drupal from scratch.
  2. "; @@ -759,6 +776,21 @@ function update_create_cache_tables() { return $ret; } +/** + * Add the update task list to the current page. + */ +function update_task_list($active = NULL) { + // Default list of tasks. + $tasks = array( + 'info' => 'Overview', + 'select' => 'Select updates', + 'run' => 'Run updates', + 'finished' => 'Review log', + ); + + drupal_set_content('left', theme_task_list($tasks, $active)); +} + // 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); -- cgit v1.2.3