Index: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.264
diff -u -p -r1.264 update.php
--- update.php	24 Oct 2008 18:47:02 -0000	1.264
+++ update.php	25 Oct 2008 21:43:53 -0000
@@ -499,7 +499,7 @@ function update_check_incompatibility($n
 
   // Store values of expensive functions for future use.
   if (empty($themes) || empty($modules)) {
-    $themes = _system_theme_data();
+    $themes = system_theme_data();
     $modules = module_rebuild_cache();
   }
 
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.632
diff -u -p -r1.632 system.module
--- modules/system/system.module	14 Oct 2008 20:44:57 -0000	1.632
+++ modules/system/system.module	25 Oct 2008 21:52:30 -0000
@@ -998,6 +998,14 @@ function system_theme_data() {
   // Extract current files from database.
   system_get_files_database($themes, 'theme');
 
+  // If we are in maintenance mode, we must not update the theme information
+  // in the database. Note that compatibility checks are already performed in
+  // update_check_incompatibility() in update.php, so this just prevents us from
+  // disabling all themes when update.php is run.
+  if (defined('MAINTENANCE_MODE')) {
+    return $themes;
+  }
+
   db_query("DELETE FROM {system} WHERE type = 'theme'");
 
   foreach ($themes as $theme) {
