diff --git a/includes/user/DefaultOptionsLookup.php b/includes/user/DefaultOptionsLookup.php index c8da7185d4a..ebe72deb320 100644 --- a/includes/user/DefaultOptionsLookup.php +++ b/includes/user/DefaultOptionsLookup.php @@ -82,13 +82,11 @@ class DefaultOptionsLookup extends UserOptionsLookup { $this->defaultOptions = $this->serviceOptions->get( 'DefaultUserOptions' ); // Default language setting - $this->defaultOptions['language'] = $this->contentLang->getCode(); + $contentLangCode = $this->contentLang->getCode(); + $this->defaultOptions['language'] = $contentLangCode; + $this->defaultOptions['variant'] = $contentLangCode; foreach ( LanguageConverter::$languagesWithVariants as $langCode ) { - if ( $langCode === $this->contentLang->getCode() ) { - $this->defaultOptions['variant'] = $langCode; - } else { - $this->defaultOptions["variant-$langCode"] = $langCode; - } + $this->defaultOptions["variant-$langCode"] = $langCode; } // NOTE: don't use SearchEngineConfig::getSearchableNamespaces here, diff --git a/tests/phpunit/includes/auth/AuthManagerTest.php b/tests/phpunit/includes/auth/AuthManagerTest.php index 4e6488798ee..1422165e7aa 100644 --- a/tests/phpunit/includes/auth/AuthManagerTest.php +++ b/tests/phpunit/includes/auth/AuthManagerTest.php @@ -751,7 +751,7 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase { return [ [ 'zh', false, 'zh', 'zh' ], [ 'zh', true, 'de', 'zh' ], - [ 'fr', true, 'de', null ], + [ 'fr', true, 'de', 'fr' ], ]; }