Allow $wgULSLanguageDetection to work if $wgULSAnonCanChangeLanguage is false

$wgULSAnonCanChangeLanguage is documented as just affecting setting of
language for anonymous users via cookies and &setlang=. But currently it also
affects the fallback to Accept-Language if $wgULSLanguageDetection is enabled.

With this, $wgULSAnonCanChangeLanguage will now only control whether cookies
and &setlang= can be used for anonymous users, and keeps
$wgULSLanguageDetection independent.

Bug: T203179
Change-Id: I6c664ad11dc18b66190dc0644352b91adf87c9e5
This commit is contained in:
Kunal Mehta
2018-09-05 15:38:27 -07:00
committed by jenkins-bot
parent aa23d555a3
commit 8ee09f0ba1
2 changed files with 15 additions and 17 deletions

View File

@@ -261,25 +261,23 @@ class UniversalLanguageSelectorHooks {
return; return;
} }
// Logged out users - less simple // If using cookie storage for anons is OK, read/write from that
if ( !$wgULSAnonCanChangeLanguage ) { if ( $wgULSAnonCanChangeLanguage ) {
return; // Language change
} if ( Language::isSupportedLanguage( $languageToSave ) ) {
$request->response()->setCookie( 'language', $languageToSave );
$code = $languageToSave;
// Language change return;
if ( Language::isSupportedLanguage( $languageToSave ) ) { }
$request->response()->setCookie( 'language', $languageToSave );
$code = $languageToSave;
return; // Try cookie
} $languageToUse = $request->getCookie( 'language', null, '' );
if ( Language::isSupportedLanguage( $languageToUse ) ) {
$code = $languageToUse;
// Try cookie return;
$languageToUse = $request->getCookie( 'language', null, '' ); }
if ( Language::isSupportedLanguage( $languageToUse ) ) {
$code = $languageToUse;
return;
} }
// As last resort, try Accept-Language headers if allowed // As last resort, try Accept-Language headers if allowed

View File

@@ -67,7 +67,7 @@
"ULSEnableAnon": true, "ULSEnableAnon": true,
"@ULSAnonCanChangeLanguage": "Allow anonymous users to change language with cookie and setlang query parameter. Do not use if you are caching anonymous page views without taking cookies into account. Does not have any effect if either of $wgULSEnable or $wgULSEnableAnon is set to false. @since 2013.04", "@ULSAnonCanChangeLanguage": "Allow anonymous users to change language with cookie and setlang query parameter. Do not use if you are caching anonymous page views without taking cookies into account. Does not have any effect if either of $wgULSEnable or $wgULSEnableAnon is set to false. @since 2013.04",
"ULSAnonCanChangeLanguage": true, "ULSAnonCanChangeLanguage": true,
"@ULSLanguageDetection": "Try to use preferred interface language for anonymous users. Do not use if you are caching anonymous page views without taking Accept-Language into account. Does not have any effect if any of $wgULSEnable, $wgULSEnableAnon or $wgULSAnonCanChangeLanguage is set to false.", "@ULSLanguageDetection": "Try to use preferred interface language for anonymous users. Do not use if you are caching anonymous page views without taking Accept-Language into account. Does not have any effect if any of $wgULSEnable, or $wgULSEnableAnon is set to false.",
"ULSLanguageDetection": true, "ULSLanguageDetection": true,
"@ULSIMEEnabled": "Enable the input methods feature for all users by default. Can be controlled by the user.", "@ULSIMEEnabled": "Enable the input methods feature for all users by default. Can be controlled by the user.",
"ULSIMEEnabled": true, "ULSIMEEnabled": true,