Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.325
diff -u -p -r1.325 bootstrap.inc
--- includes/bootstrap.inc	10 Nov 2009 22:06:09 -0000	1.325
+++ includes/bootstrap.inc	11 Nov 2009 06:56:20 -0000
@@ -122,45 +122,50 @@ define('WATCHDOG_INFO', 6);
 define('WATCHDOG_DEBUG', 7);
 
 /**
- * First bootstrap phase: initialize configuration.
+ * Bootstrap phase: initialize configuration.
  */
 define('DRUPAL_BOOTSTRAP_CONFIGURATION', 0);
 
 /**
- * Second bootstrap phase: try to serve a cached page.
+ * Bootstrap phase: try to serve a cached page.
  */
 define('DRUPAL_BOOTSTRAP_PAGE_CACHE', 1);
 
 /**
- * Third bootstrap phase: initialize database layer.
+ * Bootstrap phase: initialize database layer.
  */
 define('DRUPAL_BOOTSTRAP_DATABASE', 2);
 
 /**
- * Fourth bootstrap phase: initialize the variable system.
+ * Bootstrap phase: initialize the variable system.
  */
 define('DRUPAL_BOOTSTRAP_VARIABLES', 3);
 
 /**
- * Fifth bootstrap phase: initialize session handling.
+ * Bootstrap phase: initialize the module system.
  */
-define('DRUPAL_BOOTSTRAP_SESSION', 4);
+define('DRUPAL_BOOTSTRAP_MODULE', 4);
 
 /**
- * Sixth bootstrap phase: set up the page header.
+ * Bootstrap phase: initialize session handling.
  */
-define('DRUPAL_BOOTSTRAP_PAGE_HEADER', 5);
+define('DRUPAL_BOOTSTRAP_SESSION', 5);
 
 /**
- * Seventh bootstrap phase: find out language of the page.
+ * Bootstrap phase: set up the page header.
  */
-define('DRUPAL_BOOTSTRAP_LANGUAGE', 6);
+define('DRUPAL_BOOTSTRAP_PAGE_HEADER', 6);
+
+/**
+ * Bootstrap phase: find out language of the page.
+ */
+define('DRUPAL_BOOTSTRAP_LANGUAGE', 7);
 
 /**
  * Final bootstrap phase: Drupal is fully loaded; validate and fix
  * input data.
  */
-define('DRUPAL_BOOTSTRAP_FULL', 7);
+define('DRUPAL_BOOTSTRAP_FULL', 8);
 
 /**
  * Role ID for anonymous users; should match what's in the "role" table.
@@ -829,12 +834,17 @@ function drupal_page_is_cacheable($allow
  * Call all init or exit hooks without including all modules.
  *
  * @param $hook
- *   The name of the bootstrap hook we wish to invoke.
+ *   (optional) The name of the bootstrap hook to invoke. If omitted, all
+ *   enabled bootstrap modules will only be loaded.
+ *
+ * @see bootstrap_hooks()
  */
-function bootstrap_invoke_all($hook) {
+function bootstrap_invoke_all($hook = NULL) {
   foreach (module_list(TRUE, TRUE) as $module) {
     drupal_load('module', $module);
-    module_invoke($module, $hook);
+    if (isset($hook)) {
+      module_invoke($module, $hook);
+    }
   }
 }
 
@@ -1474,6 +1484,7 @@ function drupal_bootstrap($phase = NULL,
     DRUPAL_BOOTSTRAP_PAGE_CACHE,
     DRUPAL_BOOTSTRAP_DATABASE,
     DRUPAL_BOOTSTRAP_VARIABLES,
+    DRUPAL_BOOTSTRAP_MODULE,
     DRUPAL_BOOTSTRAP_SESSION,
     DRUPAL_BOOTSTRAP_PAGE_HEADER,
     DRUPAL_BOOTSTRAP_LANGUAGE,
@@ -1503,6 +1514,10 @@ function drupal_bootstrap($phase = NULL,
           _drupal_bootstrap_variables();
           break;
 
+        case DRUPAL_BOOTSTRAP_MODULE:
+          _drupal_bootstrap_module();
+          break;
+
         case DRUPAL_BOOTSTRAP_SESSION:
           require_once DRUPAL_ROOT . '/' . variable_get('session_inc', 'includes/session.inc');
           drupal_session_initialize();
@@ -1573,6 +1588,7 @@ function _drupal_bootstrap_page_cache() 
       // If the skipping of the bootstrap hooks is not enforced, call
       // hook_boot.
       if (variable_get('page_cache_invoke_hooks', TRUE)) {
+        require_once DRUPAL_ROOT . '/includes/module.inc';
         bootstrap_invoke_all('boot');
       }
       header('X-Drupal-Cache: HIT');
@@ -1608,23 +1624,34 @@ function _drupal_bootstrap_database() {
 }
 
 /**
- * Bootstrap variables: Load system variables and all enabled bootstrap modules.
+ * Bootstrap variables: Load system variables.
  */
 function _drupal_bootstrap_variables() {
   global $conf;
 
   // Load variables from the database, but do not overwrite variables set in settings.php.
   $conf = variable_initialize(isset($conf) ? $conf : array());
-  // Load bootstrap modules.
+}
+
+/**
+ * Bootstrap module system: Load all enabled bootstrap modules.
+ *
+ * Only modules implementing certain hooks are loaded.
+ *
+ * @see bootstrap_hooks()
+ */
+function _drupal_bootstrap_module() {
   require_once DRUPAL_ROOT . '/includes/module.inc';
-  module_load_all(TRUE);
+  bootstrap_invoke_all();
 }
 
 /**
  * Bootstrap page header: Invoke hook_boot(), intialize locking system, and send default HTTP headers.
  */
 function _drupal_bootstrap_page_header() {
+  // Invoke hook_boot() in enabled bootstrap modules.
   bootstrap_invoke_all('boot');
+
   if (!drupal_page_get_cache(TRUE) && drupal_page_is_cacheable()) {
     header('X-Drupal-Cache: MISS');
   }
Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.171
diff -u -p -r1.171 module.inc
--- includes/module.inc	10 Nov 2009 22:06:09 -0000	1.171
+++ includes/module.inc	11 Nov 2009 06:37:46 -0000
@@ -9,27 +9,24 @@
 /**
  * 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.
+ * @param $load
+ *   Whether to load all modules. Defaults to TRUE. Can be set to FALSE to only
+ *   return whether all modules have been loaded already.
  * @return
- *   If $bootstrap is NULL, return a boolean indicating whether all modules
- *   have been loaded.
+ *   A boolean indicating whether all modules were loaded.
  */
-function module_load_all($bootstrap = FALSE) {
+function module_load_all($load = TRUE) {
   static $has_run = FALSE;
 
-  if (isset($bootstrap)) {
-    foreach (module_list(TRUE, $bootstrap) as $module) {
+  if ($load) {
+    foreach (module_list(TRUE) as $module) {
       drupal_load('module', $module);
     }
-    // $has_run will be TRUE if $bootstrap is FALSE.
-    $has_run = !$bootstrap;
+    $has_run = TRUE;
   }
   return $has_run;
 }
 
-
 /**
  * Collect a list of all loaded modules. During the bootstrap, return only
  * vital modules. See bootstrap.inc
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.550
diff -u -p -r1.550 theme.inc
--- includes/theme.inc	8 Nov 2009 12:43:41 -0000	1.550
+++ includes/theme.inc	11 Nov 2009 06:37:46 -0000
@@ -261,7 +261,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 (module_load_all(NULL)) {
+    if (module_load_all(FALSE)) {
       _theme_save_registry($theme, $registry);
       _theme_set_registry($registry);
     }
