Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.585.2.23
diff -u -p -r1.585.2.23 system.module
--- modules/system/system.module	22 Oct 2008 19:36:26 -0000	1.585.2.23
+++ modules/system/system.module	25 Oct 2008 21:58:26 -0000
@@ -820,6 +820,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) {
