Use Language::equals to compare Language objects
authorFomafix <fomafix@googlemail.com>
Mon, 9 Jul 2018 04:26:57 +0000 (06:26 +0200)
committerLegoktm <legoktm@member.fsf.org>
Tue, 10 Jul 2018 01:04:03 +0000 (01:04 +0000)
With I8a47a8500922906bd4e4936b59b657de3bb9abdc Language::equals can
directly and faster compare the objects.

$wgLanguageCode can differ from $wgContLang->getCode() when a deprecated
language code is used. This change prevents this because Language
replaces deprecated language codes in Language::factory().

Change-Id: I07f47eceff8b3a4192278b1e9e1cfd9a41816a1c

includes/cache/HTMLFileCache.php

index 7ae2ee0..f8cd754 100644 (file)
@@ -91,6 +91,7 @@ class HTMLFileCache extends FileCacheBase {
         * @return bool
         */
        public static function useFileCache( IContextSource $context, $mode = self::MODE_NORMAL ) {
+               global $wgContLang;
                $config = MediaWikiServices::getInstance()->getMainConfig();
 
                if ( !$config->get( 'UseFileCache' ) && $mode !== self::MODE_REBUILD ) {
@@ -123,7 +124,7 @@ class HTMLFileCache extends FileCacheBase {
                $ulang = $context->getLanguage();
 
                // Check that there are no other sources of variation
-               if ( $user->getId() || $ulang->getCode() !== $config->get( 'LanguageCode' ) ) {
+               if ( $user->getId() || !$ulang->equals( $wgContLang ) ) {
                        return false;
                }