Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.256 diff -u -p -r1.256 bootstrap.inc --- includes/bootstrap.inc 30 Nov 2008 01:05:16 -0000 1.256 +++ includes/bootstrap.inc 30 Nov 2008 15:04:40 -0000 @@ -130,15 +130,14 @@ define('DRUPAL_BOOTSTRAP_SESSION', 4); define('DRUPAL_BOOTSTRAP_VARIABLES', 5); /** - * Seventh bootstrap phase: load bootstrap.inc and module.inc, start - * the variable system and try to serve a page from the cache. + * Seventh bootstrap phase: find out language of the page. */ -define('DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE', 6); - +define('DRUPAL_BOOTSTRAP_LANGUAGE', 6); /** - * Eighth bootstrap phase: find out language of the page. + * Eighth bootstrap phase: load bootstrap.inc and module.inc, start + * the variable system and try to serve a page from the cache. */ -define('DRUPAL_BOOTSTRAP_LANGUAGE', 7); +define('DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE', 7); /** * Nineth bootstrap phase: set $_GET['q'] to Drupal path of request. @@ -658,12 +657,12 @@ function variable_del($name) { * a redirected form submission which was completed). */ function page_get_cache() { - global $user, $base_root; + global $user; $cache = NULL; if (!$user->uid && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') && count(drupal_set_message()) == 0) { - $cache = cache_get($base_root . request_uri(), 'cache_page'); + $cache = cache_get(drupal_get_page_cache_id(), 'cache_page'); if (empty($cache)) { ob_start(); @@ -674,6 +673,17 @@ function page_get_cache() { } /** + * Helper function to retrieve a cache ID for the current page. + * + * The page cache includes the language to support cases where + * we serve different languages pages at a given path. + */ +function drupal_get_page_cache_id() { + global $base_root, $language; + return $base_root . request_uri() . $language->language; +} + +/** * Includes a file with the provided type and name. This prevents * including a theme, engine, module, etc., more than once. * @@ -1045,14 +1055,14 @@ function drupal_anonymous_user($session * DRUPAL_BOOTSTRAP_ACCESS: identify and reject banned hosts. * DRUPAL_BOOTSTRAP_SESSION: initialize session handling. * DRUPAL_BOOTSTRAP_VARIABLES: initialize variable handling. + * DRUPAL_BOOTSTRAP_LANGUAGE: identify the language used on the page. * DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE: load bootstrap.inc and module.inc, start * 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_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_LANGUAGE, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL), $completed_phase = -1; if (isset($phase)) { while ($phases && $phase > $completed_phase) { @@ -1130,6 +1140,10 @@ function _drupal_bootstrap($phase) { $conf = variable_init(isset($conf) ? $conf : array()); break; + case DRUPAL_BOOTSTRAP_LANGUAGE: + drupal_init_language(); + break; + case DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE: $cache_mode = variable_get('cache', CACHE_DISABLED); // Get the page from the cache. @@ -1154,10 +1168,6 @@ function _drupal_bootstrap($phase) { drupal_page_header(); break; - case DRUPAL_BOOTSTRAP_LANGUAGE: - drupal_init_language(); - break; - case DRUPAL_BOOTSTRAP_PATH: require_once DRUPAL_ROOT . '/includes/path.inc'; // Initialize $_GET['q'] prior to loading modules and invoking hook_init(). Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.832 diff -u -p -r1.832 common.inc --- includes/common.inc 30 Nov 2008 01:05:16 -0000 1.832 +++ includes/common.inc 30 Nov 2008 15:05:27 -0000 @@ -2813,7 +2813,7 @@ function _drupal_bootstrap_full() { * @see drupal_page_header */ function page_set_cache() { - global $user, $base_root; + global $user; if (!$user->uid && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') && count(drupal_get_messages(NULL, FALSE)) == 0) { // This will fail in some cases, see page_get_cache() for the explanation. @@ -2833,7 +2833,7 @@ function page_set_cache() { } ob_end_flush(); if ($cache && $data) { - cache_set($base_root . request_uri(), $data, 'cache_page', CACHE_TEMPORARY, drupal_get_headers()); + cache_set(drupal_get_page_cache_id(), $data, 'cache_page', CACHE_TEMPORARY, drupal_get_headers()); } } } Index: modules/simpletest/tests/bootstrap.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/bootstrap.test,v retrieving revision 1.7 diff -u -p -r1.7 bootstrap.test --- modules/simpletest/tests/bootstrap.test 23 Nov 2008 18:12:08 -0000 1.7 +++ modules/simpletest/tests/bootstrap.test 30 Nov 2008 15:05:32 -0000 @@ -183,8 +183,9 @@ class HookBootExitTestCase extends Drupa // Test with aggressive cache. Boot and exit should not fire since the // page is cached. variable_set('cache', CACHE_AGGRESSIVE); - $this->assertTrue(cache_get(url('', array('absolute' => TRUE)), 'cache_page'), t('Page has been cached.')); $this->drupalGet(''); + $this->drupalHead(''); + $this->assertText('ETag: ', t('Verify presence of ETag header indicating that page caching is enabled.')); $this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_boot'")->fetchField(), $calls, t('hook_boot not called with agressive cache and a cached page.')); $this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_exit'")->fetchField(), $calls, t('hook_exit not called with agressive cache and a cached page.'));