Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.815
diff -u -p -r1.815 common.inc
--- includes/common.inc	1 Nov 2008 21:21:34 -0000	1.815
+++ includes/common.inc	3 Nov 2008 20:47:04 -0000
@@ -3718,7 +3718,16 @@ function drupal_flush_all_caches() {
   registry_rebuild();
   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_theme_rebuild();
   menu_rebuild();
   node_types_rebuild();
