=== modified file 'includes/module.inc'
--- includes/module.inc	2009-09-29 18:08:28 +0000
+++ includes/module.inc	2009-10-07 20:44:02 +0000
@@ -6,16 +6,30 @@
  * API for loading and interacting with Drupal modules.
  */
 
-
 /**
  * Load all the modules that have been enabled in the system table.
+ * 
+ * @param $bootstrap
+ *   Whether to load only the reduced set of modules loaded in "bootstrap mode"
+ *   for cached pages. See bootstrap.inc.
+ * @return
+ *   If $bootstrap is NULL, return a boolean indicating whether all modules
+ *   have been loaded.
  */
 function module_load_all($bootstrap = FALSE) {
-  foreach (module_list(TRUE, $bootstrap) as $module) {
-    drupal_load('module', $module);
+  static $has_run = FALSE;
+
+  if (isset($bootstrap)) {
+    foreach (module_list(TRUE, $bootstrap) as $module) {
+      drupal_load('module', $module);
+    }
+    // $has_run will be TRUE if $bootstrap is FALSE.
+    $has_run = !$bootstrap;
   }
+  return $has_run;
 }
 
+
 /**
  * Collect a list of all loaded modules. During the bootstrap, return only
  * vital modules. See bootstrap.inc

=== modified file 'includes/theme.inc'
--- includes/theme.inc	2009-10-05 02:43:01 +0000
+++ includes/theme.inc	2009-10-07 20:41:43 +0000
@@ -258,7 +258,7 @@ function _theme_load_registry($theme, $b
     $registry = _theme_build_registry($theme, $base_theme, $theme_engine);
    // Only persist this registry if all modules are loaded. This assures a 
    // complete set of theme hooks.
-    if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) {
+    if (module_load_all(NULL)) {
       _theme_save_registry($theme, $registry);
       _theme_set_registry($registry);
     }

