Index: index.php
===================================================================
RCS file: /cvs/drupal/drupal/index.php,v
retrieving revision 1.97
diff -u -p -r1.97 index.php
--- index.php	27 Jan 2009 00:22:24 -0000	1.97
+++ index.php	7 Feb 2009 03:30:43 -0000
@@ -18,6 +18,8 @@
 define('DRUPAL_ROOT', dirname(realpath(__FILE__)));
 
 require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
+// @todo Required for early watchdog() messages and much more unexpected stuff.
+require_once DRUPAL_ROOT . '/includes/module.inc';
 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 $return = menu_execute_active_handler();
 
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.269
diff -u -p -r1.269 bootstrap.inc
--- includes/bootstrap.inc	31 Jan 2009 16:50:56 -0000	1.269
+++ includes/bootstrap.inc	7 Feb 2009 03:38:41 -0000
@@ -28,13 +28,6 @@ define('CACHE_DISABLED', 0);
 define('CACHE_NORMAL', 1);
 
 /**
- * Indicates that page caching is using "aggressive" mode. This bypasses
- * loading any modules for additional speed, which may break functionality in
- * modules that expect to be run on each page load.
- */
-define('CACHE_AGGRESSIVE', 2);
-
-/**
  * Log message severity -- Emergency: system is unusable.
  *
  * @see watchdog()
@@ -694,11 +687,11 @@ function variable_del($name) {
  *   may not be cached (e.g. because it belongs to an authenticated user). If
  *   $retrieve is TRUE, only return either TRUE or FALSE.
  */
-function page_get_cache($retrieve) {
+function page_get_cache($retrieve = FALSE) {
   global $user, $base_root;
   static $ob_started = FALSE;
 
-  if ($user->uid || ($_SERVER['REQUEST_METHOD'] != 'GET' && $_SERVER['REQUEST_METHOD'] != 'HEAD') || count(drupal_get_messages(NULL, FALSE))) {
+  if ((isset($_COOKIE[session_name()]) && $user->uid) || !($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['REQUEST_METHOD'] == 'HEAD') || count(drupal_get_messages(NULL, FALSE))) {
     return FALSE;
   }
   if ($retrieve) {
@@ -715,6 +708,23 @@ function page_get_cache($retrieve) {
 }
 
 /**
+ * Deliver the current page from cache.
+ *
+ * @return
+ *   The cached page output.
+ */
+function page_deliver_cache($cache) {
+  if (variable_get('cache_page_invoke_hooks', TRUE)) {
+    require_once DRUPAL_ROOT . '/includes/module.inc';
+    module_invoke_all('boot');
+  }
+  drupal_page_cache_header($cache);
+  if (variable_get('cache_page_invoke_hooks', TRUE)) {
+    module_invoke_all('exit');
+  }
+}
+
+/**
  * Includes a file with the provided type and name. This prevents
  * including a theme, engine, module, etc., more than once.
  *
@@ -1093,7 +1103,19 @@ function drupal_anonymous_user($session 
  *     DRUPAL_BOOTSTRAP_FULL: Drupal is fully loaded, validate and fix input data.
  */
 function drupal_bootstrap($phase = NULL) {
-  static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_VARIABLES, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL), $completed_phase = -1;
+  static $phases = array(
+    DRUPAL_BOOTSTRAP_CONFIGURATION,
+    DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE,
+    DRUPAL_BOOTSTRAP_DATABASE,
+    DRUPAL_BOOTSTRAP_ACCESS,
+    DRUPAL_BOOTSTRAP_SESSION,
+    DRUPAL_BOOTSTRAP_VARIABLES,
+    DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE,
+    DRUPAL_BOOTSTRAP_LANGUAGE,
+    DRUPAL_BOOTSTRAP_PATH,
+    DRUPAL_BOOTSTRAP_FULL,
+  );
+  static $completed_phase = -1;
 
   if (isset($phase)) {
     while ($phases && $phase > $completed_phase) {
@@ -1133,12 +1155,13 @@ function _drupal_bootstrap($phase) {
       // Allow specifying special cache handlers in settings.php, like
       // using memcached or files for storing cache information.
       require_once DRUPAL_ROOT . '/' . variable_get('cache_inc', 'includes/cache.inc');
-      // If the page_cache_fastpath is set to TRUE in settings.php and
-      // page_cache_fastpath (implemented in the special implementation of
-      // cache.inc) printed the page and indicated this with a returned TRUE
-      // then we are done.
-      if (variable_get('page_cache_fastpath', FALSE) && page_cache_fastpath()) {
-        exit;
+      $cache_mode = variable_get('cache', CACHE_DISABLED);
+      if ($cache_mode != CACHE_DISABLED && !isset($_COOKIE[session_name()])) {
+        $cache = page_get_cache(TRUE);
+        if (is_object($cache)) {
+          page_deliver_cache($cache);
+          exit;
+        }
       }
       break;
 
@@ -1183,36 +1206,20 @@ function _drupal_bootstrap($phase) {
     case DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE:
       $cache_mode = variable_get('cache', CACHE_DISABLED);
       // Get the page from the cache.
-      $cache = $cache_mode == CACHE_DISABLED ? FALSE : page_get_cache(TRUE);
-      // If the skipping of the bootstrap hooks is not enforced, call hook_boot.
-      if (!is_object($cache) || $cache_mode != CACHE_AGGRESSIVE) {
-        // Load module handling.
-        require_once DRUPAL_ROOT . '/includes/module.inc';
-        module_invoke_all('boot');
-      }
-      // If there is a cached page, display it.
-      if (is_object($cache)) {
-        // Destroy empty anonymous sessions.
-        if (drupal_session_is_started() && empty($_SESSION)) {
-          session_destroy();
-        }
-        drupal_page_cache_header($cache);
-        // If the skipping of the bootstrap hooks is not enforced, call hook_exit.
-        if ($cache_mode != CACHE_AGGRESSIVE) {
-          module_invoke_all('exit');
-        }
-        // We are done.
-        exit;
-      }
+      $cache = ($cache_mode == CACHE_DISABLED ? FALSE : page_get_cache(TRUE));
       // Prepare for non-cached page workflow.
       drupal_page_header();
       // If the session has not already been started and output buffering is
       // not enabled, the session must be started now before the HTTP headers
       // are sent. If output buffering is enabled, the session may be started
       // at any time using drupal_session_start().
-      if ($cache === FALSE) {
+      if ($cache === FALSE || !is_object($cache)) {
         drupal_session_start();
       }
+      else if (is_object($cache)) {
+        page_deliver_cache($cache);
+        exit;
+      }
       break;
 
     case DRUPAL_BOOTSTRAP_LANGUAGE:
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.864
diff -u -p -r1.864 common.inc
--- includes/common.inc	5 Feb 2009 01:21:16 -0000	1.864
+++ includes/common.inc	7 Feb 2009 02:16:48 -0000
@@ -2976,7 +2976,9 @@ function _drupal_bootstrap_full() {
   // Undo magic quotes
   fix_gpc_magic();
   // Load all enabled modules
-  module_load_all();
+  if (drupal_function_exists('module_load_all')) {
+    module_load_all();
+  }
 
   // Let all modules take action before menu system handles the request
   // We do not want this while running update.php.
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.124
diff -u -p -r1.124 system.admin.inc
--- modules/system/system.admin.inc	3 Feb 2009 18:55:31 -0000	1.124
+++ modules/system/system.admin.inc	7 Feb 2009 02:28:19 -0000
@@ -1309,15 +1309,6 @@ function system_performance_settings() {
     $description .= '<p>' . t("When caching is enabled, anonymous user sessions are only saved to the database when needed, so the \"Who's online\" block does not display the number of anonymous users.") . '</p>';
   }
 
-  $problem_modules = array_unique(array_merge(module_implements('boot'), module_implements('exit')));
-  sort($problem_modules);
-
-  if (count($problem_modules) > 0) {
-    $description .= '<p>' . t('<strong class="error">The following enabled modules are incompatible with aggressive mode caching and will not function properly: %modules</strong>', array('%modules' => implode(', ', $problem_modules))) . '.</p>';
-  }
-  else {
-    $description .= '<p>' . t('<strong class="ok">Currently, all enabled modules are compatible with the aggressive caching policy.</strong> Please note, if you use aggressive caching and enable new modules, you will need to check this page again to ensure compatibility.') . '</p>';
-  }
   $form['page_cache'] = array(
     '#type' => 'fieldset',
     '#title' => t('Page cache'),
@@ -1328,7 +1319,7 @@ function system_performance_settings() {
     '#type' => 'radios',
     '#title' => t('Caching mode'),
     '#default_value' => variable_get('cache', CACHE_DISABLED),
-    '#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_NORMAL => t('Normal (recommended for production sites, no side effects)'), CACHE_AGGRESSIVE => t('Aggressive (experts only, possible side effects)')),
+    '#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_NORMAL => t('Normal (recommended for production sites)')),
     '#description' => $description
   );
 
Index: sites/default/default.settings.php
===================================================================
RCS file: /cvs/drupal/drupal/sites/default/default.settings.php,v
retrieving revision 1.18
diff -u -p -r1.18 default.settings.php
--- sites/default/default.settings.php	23 Dec 2008 19:59:17 -0000	1.18
+++ sites/default/default.settings.php	7 Feb 2009 02:24:27 -0000
@@ -311,3 +311,11 @@ ini_set('session.cookie_lifetime', 20000
 # $conf['blocked_ips'] = array(
 #   'a.b.c.d',
 # );
+
+/**
+ * Page caching behavior.
+ *
+ * To bypass hook_boot() and hook_exit() implementations in modules, set this
+ * variable to FALSE.
+ */
+# $conf['cache_page_invoke_hooks'] = FALSE;
