Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -209,11 +209,11 @@ |
210 | 210 | ( ( !isset($this->GET['title']) || $title->getPrefixedDBKey() != $this->GET['title'] ) || |
211 | 211 | // No valid variant in URL (if the main-language has multi-variants), to ensure |
212 | 212 | // 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() ) ) && |
215 | 214 | !count( array_diff( array_keys( $this->GET ), array( 'action', 'title' ) ) ) ) |
216 | 215 | { |
217 | | - $targetUrl = $title->getFullURL(); |
| 216 | + $pref = $wgContLang->getPreferredVariant( $fromUser = false, $fromHeader = true ); |
| 217 | + $targetUrl = $title->getFullURL( $variant = $pref ); |
218 | 218 | // Redirect to canonical url, make it a 301 to allow caching |
219 | 219 | if( $targetUrl == $request->getFullRequestURL() ) { |
220 | 220 | $message = "Redirect loop detected!\n\n" . |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -126,10 +126,11 @@ |
127 | 127 | /** |
128 | 128 | * get preferred language variants. |
129 | 129 | * @param boolean $fromUser Get it from $wgUser's preferences |
| 130 | + * @param boolean $fromHeader Get it from Accept-Language |
130 | 131 | * @return string the preferred language code |
131 | 132 | * @public |
132 | 133 | */ |
133 | | - function getPreferredVariant( $fromUser = true ) { |
| 134 | + function getPreferredVariant( $fromUser = true, $fromHeader = false ) { |
134 | 135 | global $wgUser, $wgRequest, $wgVariantArticlePath, $wgDefaultLanguageVariant, $wgOut; |
135 | 136 | |
136 | 137 | if($this->mPreferredVariant) |
— | — | @@ -184,7 +185,7 @@ |
185 | 186 | // http header, but we don't set the mPreferredVariant |
186 | 187 | // variable in case this is called before the user's |
187 | 188 | // preference is loaded |
188 | | - if( array_key_exists( 'HTTP_ACCEPT_LANGUAGE', $_SERVER ) ) { |
| 189 | + if( $fromHeader && array_key_exists( 'HTTP_ACCEPT_LANGUAGE', $_SERVER ) ) { |
189 | 190 | |
190 | 191 | // bug 21672: Add Accept-Language to Vary and XVO headers |
191 | 192 | // to help Squid to determine user's perferred local language |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -2369,8 +2369,8 @@ |
2370 | 2370 | } |
2371 | 2371 | |
2372 | 2372 | |
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 ); |
2375 | 2375 | } |
2376 | 2376 | |
2377 | 2377 | /** |