Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.206.2.9 diff -u -p -r1.206.2.9 bootstrap.inc --- includes/bootstrap.inc 14 Jan 2009 19:10:25 -0000 1.206.2.9 +++ includes/bootstrap.inc 19 Feb 2009 14:54:04 -0000 @@ -76,15 +76,15 @@ define('DRUPAL_BOOTSTRAP_ACCESS', 3); define('DRUPAL_BOOTSTRAP_SESSION', 4); /** - * Sixth bootstrap phase: load bootstrap.inc and module.inc, start - * the variable system and try to serve a page from the cache. + * Sixth bootstrap phase: find out language of the page. */ -define('DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE', 5); +define('DRUPAL_BOOTSTRAP_LANGUAGE', 5); /** - * Seventh bootstrap phase: find out language of the page. + * Seventh 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', 6); +define('DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE', 6); /** * Eighth bootstrap phase: set $_GET['q'] to Drupal path of request. @@ -956,14 +956,14 @@ function drupal_anonymous_user($session * DRUPAL_BOOTSTRAP_DATABASE: initialize database layer. * DRUPAL_BOOTSTRAP_ACCESS: identify and reject banned hosts. * DRUPAL_BOOTSTRAP_SESSION: initialize session 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) { - static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL), $phase_index = 0; + static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL), $phase_index = 0; while ($phase >= $phase_index && isset($phases[$phase_index])) { $current_phase = $phases[$phase_index]; @@ -973,7 +973,7 @@ function drupal_bootstrap($phase) { } function _drupal_bootstrap($phase) { - global $conf; + global $conf, $no_cache; switch ($phase) { @@ -1019,12 +1019,16 @@ function _drupal_bootstrap($phase) { session_start(); break; + case DRUPAL_BOOTSTRAP_LANGUAGE: + drupal_init_language(); + break; + case DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE: // Initialize configuration variables, using values from settings.php if available. $conf = variable_init(isset($conf) ? $conf : array()); $cache_mode = variable_get('cache', CACHE_DISABLED); // Get the page from the cache. - $cache = $cache_mode == CACHE_DISABLED ? '' : page_get_cache(); + $cache = $cache_mode == CACHE_DISABLED || $no_cache == TRUE ? FALSE : page_get_cache(TRUE); // If the skipping of the bootstrap hooks is not enforced, call hook_boot. if (!$cache || $cache_mode != CACHE_AGGRESSIVE) { // Load module handling. @@ -1045,10 +1049,6 @@ function _drupal_bootstrap($phase) { drupal_page_header(); break; - case DRUPAL_BOOTSTRAP_LANGUAGE: - drupal_init_language(); - break; - case DRUPAL_BOOTSTRAP_PATH: require_once './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.756.2.45 diff -u -p -r1.756.2.45 common.inc --- includes/common.inc 16 Feb 2009 13:18:03 -0000 1.756.2.45 +++ includes/common.inc 19 Feb 2009 14:54:05 -0000 @@ -1568,7 +1568,8 @@ function l($text, $path, $options = arra * react to the closing of the page by calling hook_exit(). */ function drupal_page_footer() { - if (variable_get('cache', CACHE_DISABLED) != CACHE_DISABLED) { + global $no_cache; + if (variable_get('cache', CACHE_DISABLED) != CACHE_DISABLED && $no_cache != TRUE) { page_set_cache(); } Index: includes/language.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/language.inc,v retrieving revision 1.14.2.1 diff -u -p -r1.14.2.1 language.inc --- includes/language.inc 2 Jan 2009 23:37:48 -0000 1.14.2.1 +++ includes/language.inc 19 Feb 2009 14:54:06 -0000 @@ -10,7 +10,7 @@ * Choose a language for the page, based on language negotiation settings. */ function language_initialize() { - global $user; + global $user, $no_cache; // Configured presentation language mode. $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE); @@ -59,6 +59,12 @@ function language_initialize() { // Browser accept-language parsing. if ($language = language_from_browser()) { + + // If the language is set from browser preferences, set $no_cache to TRUE + // to avoid caching the page in this language for subsequent requests. + if ($language != language_default()) { + $no_cache = TRUE; + } return $language; }