Check fallbacks correctly in getHeaderVariant().
authorLiangent <liangent@gmail.com>
Thu, 23 Aug 2012 19:21:01 +0000 (03:21 +0800)
committerLiangent <liangent@gmail.com>
Thu, 23 Aug 2012 19:21:01 +0000 (03:21 +0800)
Currently when users with Accept-Language: en accesses a zh site,
getVariantFallbacks() returns zh for it and zh is treated as their
preferred variant as header variant, making the configuration
setting $wgDefaultLanguageVariant ignored.

Per comments above getVariantFallbacks(), it returns the main
language code for an unknown variant (en in this case), so when
it's returning the main code, just ignore this fallback (when the
user is really sending Accept-Language: zh, it can be caught by
validateVariant() above and fallbacks are not consulted).

Change-Id: I187bdcd70b778883cc80ceeab005de3aca2e286a

languages/LanguageConverter.php

index cbd5d9a..8b7d6cb 100644 (file)
@@ -295,7 +295,7 @@ class LanguageConverter {
                        // We record these fallback variants, and process
                        // them later.
                        $fallbacks = $this->getVariantFallbacks( $language );
-                       if ( is_string( $fallbacks ) ) {
+                       if ( is_string( $fallbacks ) && $fallbacks !== $this->mMainLanguageCode ) {
                                $fallbackLanguages[] = $fallbacks;
                        } elseif ( is_array( $fallbacks ) ) {
                                $fallbackLanguages =