user: Add default value for all "variant" user option keys

Without a default the preference is treat as unknown and possible values
identical to the default are not excluded from javascript code or
database.

Bug: T291748
Change-Id: I37cf1cd87a5ef1fd91aba0c3cc4b0e3f9c9c08b4
This commit is contained in:
Umherirrender 2021-09-29 02:46:36 +02:00 committed by Krinkle
parent 0d675c382b
commit 1b334a48e9
2 changed files with 5 additions and 7 deletions

View file

@ -82,14 +82,12 @@ 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;
}
}
// NOTE: don't use SearchEngineConfig::getSearchableNamespaces here,
// since extensions may change the set of searchable namespaces depending

View file

@ -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' ],
];
}