summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org>2006-03-28 09:29:23 +0000
committerGerhard Killesreiter <killes_www_drop_org@227.no-reply.drupal.org>2006-03-28 09:29:23 +0000
commitcb49e19e9ed2e90a4ece7a5479a4f6e3d342925f (patch)
tree8bc6c50a09b84c4232fb2c8eafff42c25d5d8da7
parenta76ee6c9ed66e61211bb05bfe9dd6229918557af (diff)
downloadbrdo-cb49e19e9ed2e90a4ece7a5479a4f6e3d342925f.tar.gz
brdo-cb49e19e9ed2e90a4ece7a5479a4f6e3d342925f.tar.bz2
#54003, Watchdog not logging update errors, patch by Steven
-rw-r--r--includes/common.inc3
-rw-r--r--includes/theme.inc11
-rw-r--r--misc/progress.js2
-rw-r--r--misc/update.js12
-rw-r--r--update.php36
5 files changed, 46 insertions, 18 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 196fbab6f..e3e65528f 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -452,7 +452,8 @@ function error_handler($errno, $message, $filename, $line) {
$types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning');
$entry = $types[$errno] .': '. $message .' in '. $filename .' on line '. $line .'.';
- if (variable_get('error_level', 1) == 1) {
+ // Note: force display of error messages in update.php
+ if (variable_get('error_level', 1) == 1 || strstr($_SERVER['PHP_SELF'], 'update.php')) {
drupal_set_message($entry, 'error');
}
diff --git a/includes/theme.inc b/includes/theme.inc
index c0e4f3b0c..ec085d946 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -425,10 +425,11 @@ function theme_page($content) {
return $output;
}
-function theme_maintenance_page($content) {
+function theme_maintenance_page($content, $messages = TRUE, $partial = FALSE) {
drupal_set_header('Content-Type: text/html; charset=utf-8');
theme('add_style', 'misc/maintenance.css');
drupal_set_html_head('<link rel="shortcut icon" href="'. base_path() .'misc/favicon.ico" type="image/x-icon" />');
+
$output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
$output .= '<html xmlns="http://www.w3.org/1999/xhtml">';
$output .= '<head>';
@@ -439,13 +440,17 @@ function theme_maintenance_page($content) {
$output .= '<body>';
$output .= '<h1>' . drupal_get_title() . '</h1>';
- $output .= theme('status_messages');
+ if ($messages) {
+ $output .= theme('status_messages');
+ }
$output .= "\n<!-- begin content -->\n";
$output .= $content;
$output .= "\n<!-- end content -->\n";
- $output .= '</body></html>';
+ if (!$partial) {
+ $output .= '</body></html>';
+ }
return $output;
}
diff --git a/misc/progress.js b/misc/progress.js
index cc029e5b5..b519f066b 100644
--- a/misc/progress.js
+++ b/misc/progress.js
@@ -107,7 +107,7 @@ progressBar.prototype.receivePing = function (string, xmlhttp, pb) {
progressBar.prototype.displayError = function (string) {
var error = document.createElement('div');
error.className = 'error';
- error.appendChild(document.createTextNode(string));
+ error.innerHTML = string;
this.element.style.display = 'none';
this.element.parentNode.insertBefore(error, this.element);
diff --git a/misc/update.js b/misc/update.js
index 1dbfdb10e..9177296a1 100644
--- a/misc/update.js
+++ b/misc/update.js
@@ -7,15 +7,21 @@ if (isJsEnabled()) {
}
if ($('progress')) {
- updateCallback = function (progress, status, pb) {
+ // Success: redirect to the summary.
+ var updateCallback = function (progress, status, pb) {
if (progress == 100) {
pb.stopMonitoring();
window.location = window.location.href.split('op=')[0] +'op=finished';
}
}
- errorCallback = function (pb) {
- window.location = window.location.href.split('op=')[0] +'op=error';
+ // Failure: point out error message and provide link to the summary.
+ var errorCallback = function (pb) {
+ var div = document.createElement('p');
+ div.className = 'error';
+ div.innerHTML = 'An unrecoverable error has occured. You can find the error message below. It is advised to copy it to the clipboard for reference. Please continue to the <a href="update.php?op=error">update summary</a>';
+ $('progress').insertBefore(div, $('progress').firstChild);
+ $('wait').style.display = 'none';
}
var progress = new progressBar('updateprogress', updateCallback, HTTPPost, errorCallback);
diff --git a/update.php b/update.php
index 973ed1c8d..403d4b716 100644
--- a/update.php
+++ b/update.php
@@ -383,12 +383,13 @@ function update_update_page() {
}
function update_progress_page() {
- drupal_add_js('misc/progress.js');
- drupal_add_js('misc/update.js');
+ // Prevent browser from using cached drupal.js or update.js
+ drupal_add_js('misc/progress.js', TRUE);
+ drupal_add_js('misc/update.js', TRUE);
drupal_set_title('Updating');
$output = '<div id="progress"></div>';
- $output .= '<p>Please wait while your site is being updated.</p>';
+ $output .= '<p id="wait">Please wait while your site is being updated.</p>';
return $output;
}
@@ -434,6 +435,8 @@ function update_do_update_page() {
return '';
}
+ // Error handling: if PHP dies, the output will fail to parse as JSON, and
+ // the Javascript will tell the user to continue to the op=error page.
list($percentage, $message) = update_do_updates();
print drupal_to_js(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message));
}
@@ -442,11 +445,15 @@ function update_do_update_page() {
* Perform updates for the non-JS version and return the status page.
*/
function update_progress_page_nojs() {
+ drupal_set_title('Updating');
+
$new_op = 'do_update_nojs';
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
- // Store a fallback redirect in case of a fatal PHP error
+ // Error handling: if PHP dies, it will output whatever is in the output
+ // buffer, followed by the error message.
ob_start();
- print '<html><head><meta http-equiv="Refresh" content="0; URL=update.php?op=error"></head></html>';
+ $fallback = '<p class="error">An unrecoverable error has occured. You can find the error message below. It is advised to copy it to the clipboard for reference. Please continue to the <a href="update.php?op=error">update summary</a>.</p><p class="error">';
+ print theme('maintenance_page', $fallback, FALSE, TRUE);
list($percentage, $message) = update_do_updates();
if ($percentage == 100) {
@@ -463,11 +470,12 @@ function update_progress_page_nojs() {
}
drupal_set_html_head('<meta http-equiv="Refresh" content="0; URL=update.php?op='. $new_op .'">');
- drupal_set_title('Updating');
$output = theme('progress_bar', $percentage, $message);
$output .= '<p>Updating your site will take a few seconds.</p>';
- return $output;
+ // Note: do not output drupal_set_message()s until the summary page.
+ print theme('maintenance_page', $output, FALSE);
+ return NULL;
}
function update_finished_page($success) {
@@ -476,15 +484,17 @@ function update_finished_page($success) {
$links[] = '<a href="'. base_path() .'">main page</a>';
$links[] = '<a href="'. base_path() .'?q=admin">administration pages</a>';
+ // Report end result
if ($success) {
$output = '<p>Updates were attempted. If you see no failures below, you may proceed happily to the <a href="index.php?q=admin">administration pages</a>. Otherwise, you may need to update your database manually. All errors have been <a href="index.php?q=admin/logs">logged</a>.</p>';
}
else {
- $output = '<p class="error">The update process did not complete. All errors have been <a href="index.php?q=admin/logs">logged</a>. You may need to check the <code>watchdog</code> table manually.';
+ $update = reset($_SESSION['update_remaining']);
+ $output = '<p class="error">The update process was aborted prematurely while running <strong>update #'. $update['version'] .' in '. $update['module'] .'.module</strong>. All other errors have been <a href="index.php?q=admin/logs">logged</a>. You may need to check the <code>watchdog</code> database table manually.</p>';
}
if ($GLOBALS['access_check'] == FALSE) {
- $output .= "<p><strong>Reminder: don't forget to set the <code>\$access_check</code> value at the top of <code>update.php</code> back to <code>TRUE</code>.</strong>";
+ $output .= "<p><strong>Reminder: don't forget to set the <code>\$access_check</code> value at the top of <code>update.php</code> back to <code>TRUE</code>.</strong></p>";
}
$output .= theme('item_list', $links);
@@ -638,17 +648,23 @@ function update_convert_table_utf8($table) {
}
// Some unavoidable errors happen because the database is not yet up-to-date.
-// We suppress them to avoid confusion. All errors are still logged.
+// Our custom error handler is not yet installed, so we just surpress them.
ini_set('display_errors', FALSE);
include_once './includes/bootstrap.inc';
update_fix_system_table();
update_fix_access_table();
+
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_maintenance_theme();
+// Turn error reporting back on. From now on, only fatal errors (which are
+// not passed through the error handler) will cause a message to be printed.
+ini_set('display_errors', TRUE);
+
// Access check:
if (($access_check == FALSE) || ($user->uid == 1)) {
+
include_once './includes/install.inc';
update_fix_schema_version();