r59735 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59734‎ | r59735 | r59736 >
Date:15:47, 4 December 2009
Author:philip
Status:deferred
Tags:
Comment:
follow-up r59522 and r59541. To make the condition when we'll use Accept-Language in Vary and XVO more clear.
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Wiki.php
@@ -209,11 +209,11 @@
210210 ( ( !isset($this->GET['title']) || $title->getPrefixedDBKey() != $this->GET['title'] ) ||
211211 // No valid variant in URL (if the main-language has multi-variants), to ensure
212212 // the Accept-Language would only be added to XVO when a 301 redirection happened
213 - ( !isset($this->GET['variant']) && $perferred != $wgContLang->getCode() &&
214 - $wgContLang->hasVariants() && !$wgUser->isLoggedIn() ) ) &&
 213+ ( !isset($this->GET['variant']) && $wgContLang->hasVariants() && !$wgUser->isLoggedIn() ) ) &&
215214 !count( array_diff( array_keys( $this->GET ), array( 'action', 'title' ) ) ) )
216215 {
217 - $targetUrl = $title->getFullURL();
 216+ $pref = $wgContLang->getPreferredVariant( $fromUser = false, $fromHeader = true );
 217+ $targetUrl = $title->getFullURL( $variant = $pref );
218218 // Redirect to canonical url, make it a 301 to allow caching
219219 if( $targetUrl == $request->getFullRequestURL() ) {
220220 $message = "Redirect loop detected!\n\n" .
Index: trunk/phase3/languages/LanguageConverter.php
@@ -126,10 +126,11 @@
127127 /**
128128 * get preferred language variants.
129129 * @param boolean $fromUser Get it from $wgUser's preferences
 130+ * @param boolean $fromHeader Get it from Accept-Language
130131 * @return string the preferred language code
131132 * @public
132133 */
133 - function getPreferredVariant( $fromUser = true ) {
 134+ function getPreferredVariant( $fromUser = true, $fromHeader = false ) {
134135 global $wgUser, $wgRequest, $wgVariantArticlePath, $wgDefaultLanguageVariant, $wgOut;
135136
136137 if($this->mPreferredVariant)
@@ -184,7 +185,7 @@
185186 // http header, but we don't set the mPreferredVariant
186187 // variable in case this is called before the user's
187188 // preference is loaded
188 - if( array_key_exists( 'HTTP_ACCEPT_LANGUAGE', $_SERVER ) ) {
 189+ if( $fromHeader && array_key_exists( 'HTTP_ACCEPT_LANGUAGE', $_SERVER ) ) {
189190
190191 // bug 21672: Add Accept-Language to Vary and XVO headers
191192 // to help Squid to determine user's perferred local language
Index: trunk/phase3/languages/Language.php
@@ -2369,8 +2369,8 @@
23702370 }
23712371
23722372
2373 - function getPreferredVariant( $fromUser = true ) {
2374 - return $this->mConverter->getPreferredVariant( $fromUser );
 2373+ function getPreferredVariant( $fromUser = true, $fromHeader = false ) {
 2374+ return $this->mConverter->getPreferredVariant( $fromUser, $fromHeader );
23752375 }
23762376
23772377 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r59754follow-up r59522 and r59735. only redirect to a variant URL when logged out.philip05:39, 5 December 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59522bug 21672: Add Accept-Language to Vary and XVO headers to help Squid to deter...philip19:13, 28 November 2009
r59541follow-up r59522, r59523, r59527, r59529, r59530....philip06:47, 29 November 2009

Status & tagging log