=== modified file 'includes/common.inc'
--- includes/common.inc	2008-10-31 02:23:24 +0000
+++ includes/common.inc	2008-11-01 04:49:31 +0000
@@ -669,6 +669,25 @@ function _drupal_exception_handler($exce
 function _drupal_log_error($type, $message, $backtrace, $fatal) {
   $caller = _drupal_get_last_caller($backtrace);
 
+  if (defined('MAINTENANCE_MODE')) {
+    $t = get_t();
+    $message = $t('@type: @message in @function (line @line of @file).', array('@type' => $type, '@message' => $message, '@function' => $caller['function'], '@line' => $caller['line'], '@file' => $caller['file']));
+    if (isset($_GET['op']) && in_array($_GET['op'], array('do', 'do_nojs', 'start')) && isset($_GET['id'])) {
+      // Likely we are in a batch so we print as little as possible. We are
+      // in maintenance mode anyways, so it's unlikely that it's any other
+      // random page.
+      print "<html><body><span>$message</span></body></html>";
+    }
+    else {
+      drupal_maintenance_theme();
+      print theme('maintenance_page', $message);
+    }
+    if ($fatal) {
+      exit;
+    }
+    return;
+  }
+
   // Initialize a maintenance theme early if the boostrap was not complete.
   // Do it early because drupal_set_message() triggers an init_theme().
   if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {

=== modified file 'includes/theme.maintenance.inc'
--- includes/theme.maintenance.inc	2008-10-26 18:06:38 +0000
+++ includes/theme.maintenance.inc	2008-11-01 04:14:56 +0000
@@ -230,9 +230,12 @@ function template_preprocess_maintenance
     $variables['layout'] = ($variables['layout'] == 'left') ? 'both' : 'right';
   }
 
-  // Construct page title
-  if (drupal_get_title()) {
-    $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal'));
+  // Construct page title. We can't use drupal_get_title() here because during
+  // update.php it would try to call menu_set_active_title which does not work.
+  // It's easier to call the raw drupal_set_title() than to make
+  // drupal_get_title work for this edge case.
+  if (drupal_set_title()) {
+    $head_title = array(strip_tags(drupal_set_title()), variable_get('site_name', 'Drupal'));
   }
   else {
     $head_title = array(variable_get('site_name', 'Drupal'));
@@ -262,7 +265,7 @@ function template_preprocess_maintenance
   $variables['styles']            = drupal_get_css();
   $variables['scripts']           = drupal_get_js();
   $variables['tabs']              = '';
-  $variables['title']             = drupal_get_title();
+  $variables['title']             = drupal_set_title();
   $variables['closure']           = '';
 
   // Compile a list of classes that are going to be applied to the body element.

