Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.293
diff -U3 -r1.293 bootstrap.inc
--- includes/bootstrap.inc	4 Aug 2009 04:02:25 -0000	1.293
+++ includes/bootstrap.inc	6 Aug 2009 18:00:25 -0000
@@ -146,10 +146,15 @@
 define('DRUPAL_BOOTSTRAP_PATH', 8);
 
 /**
+ * Tenth bootstrap phase: load core but stop before loading modules.
+ */
+define('DRUPAL_BOOTSTRAP_CORE', 9);
+
+/**
  * Final bootstrap phase: Drupal is fully loaded; validate and fix
  * input data.
  */
-define('DRUPAL_BOOTSTRAP_FULL', 9);
+define('DRUPAL_BOOTSTRAP_FULL', 10);
 
 /**
  * Role ID for anonymous users; should match what's in the "role" table.
@@ -1357,6 +1362,7 @@
  *       the variable system and try to serve a page from the cache.
  *     DRUPAL_BOOTSTRAP_LANGUAGE: identify the language used on the page.
  *     DRUPAL_BOOTSTRAP_PATH: set $_GET['q'] to Drupal path of request.
+ *     DRUPAL_BOOTSTRAP_CORE: load core but stop before loading modules.
  *     DRUPAL_BOOTSTRAP_FULL: Drupal is fully loaded, validate and fix input data.
  */
 function drupal_bootstrap($phase = NULL) {
@@ -1370,6 +1376,7 @@
     DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE,
     DRUPAL_BOOTSTRAP_LANGUAGE,
     DRUPAL_BOOTSTRAP_PATH,
+    DRUPAL_BOOTSTRAP_CORE,
     DRUPAL_BOOTSTRAP_FULL,
   ));
   $completed_phase = &drupal_static(__FUNCTION__ . '_completed_phase', -1);
@@ -1507,8 +1514,12 @@
       drupal_path_initialize();
       break;
 
+    case DRUPAL_BOOTSTRAP_CORE:
+      require_once DRUPAL_ROOT . '/includes/common.inc';      
+      _drupal_bootstrap_core();
+      break;
+
     case DRUPAL_BOOTSTRAP_FULL:
-      require_once DRUPAL_ROOT . '/includes/common.inc';
       _drupal_bootstrap_full();
       break;
   }
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.954
diff -U3 -r1.954 common.inc
--- includes/common.inc	5 Aug 2009 15:58:34 -0000	1.954
+++ includes/common.inc	6 Aug 2009 18:00:30 -0000
@@ -3479,7 +3479,7 @@
   return (($skip_anonymous && $user->uid == 0) || ($token == md5(session_id() . $value . variable_get('drupal_private_key', ''))));
 }
 
-function _drupal_bootstrap_full() {
+function _drupal_bootstrap_core() {
   $called = &drupal_static(__FUNCTION__);
 
   if ($called) {
@@ -3514,10 +3514,22 @@
   unicode_check();
   // Undo magic quotes
   fix_gpc_magic();
+  // Make sure all stream wrappers are registered.
+  file_get_stream_wrappers();
+}
+
+function _drupal_bootstrap_full() {
+  $called = &drupal_static(__FUNCTION__);
+
+  if ($called) {
+    return;
+  }
+  $called = 1;
+
   // Load all enabled modules
   module_load_all();
   // Make sure all stream wrappers are registered.
-  file_get_stream_wrappers();
+  file_get_stream_wrappers(TRUE);
   // Let all modules take action before menu system handles the request
   // We do not want this while running update.php.
   if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
Index: includes/file.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/file.inc,v
retrieving revision 1.179
diff -U3 -r1.179 file.inc
--- includes/file.inc	2 Aug 2009 05:43:54 -0000	1.179
+++ includes/file.inc	6 Aug 2009 18:00:32 -0000
@@ -108,10 +108,10 @@
  * @see hook_stream_wrappers()
  * @see hook_stream_wrappers_alter()
  */
-function file_get_stream_wrappers() {
+function file_get_stream_wrappers($refresh = FALSE) {
   $wrappers = &drupal_static(__FUNCTION__);
 
-  if (!isset($wrappers)) {
+  if (!isset($wrappers) || $refresh) {
     $wrappers = module_invoke_all('stream_wrappers');
     drupal_alter('stream_wrappers', $wrappers);
     $existing = stream_get_wrappers();
