Index: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.252
diff -u -p -r1.252 update.php
--- update.php	3 Feb 2008 18:41:16 -0000	1.252
+++ update.php	8 Dec 2008 03:35:15 -0000
@@ -448,7 +448,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: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.756.2.32
diff -u -p -r1.756.2.32 common.inc
--- includes/common.inc	3 Dec 2008 12:33:11 -0000	1.756.2.32
+++ includes/common.inc	8 Dec 2008 03:35:17 -0000
@@ -3632,7 +3632,16 @@ function drupal_flush_all_caches() {
 
   drupal_clear_css_cache();
   drupal_clear_js_cache();
-  system_theme_data();
+
+  // If invoked from update.php, we must not update the theme information in the
+  // database, or this will result in all themes being disabled.
+  if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') {
+    _system_theme_data();
+  }
+  else {
+    system_theme_data();
+  }
+
   drupal_rebuild_theme_registry();
   menu_rebuild();
   node_types_rebuild();
