Merge "Allow `languageinheader` query param to fully control treatment of languages"

This commit is contained in:
jenkins-bot 2021-05-13 20:04:15 +00:00 committed by Gerrit Code Review
commit 234659e3e3
2 changed files with 36 additions and 5 deletions

View File

@ -91,15 +91,14 @@ final class LanguageInHeaderTreatmentRequirement implements Requirement {
* @throws \ConfigException
*/
public function isMet() : bool {
if ( $this->request->getCheck( Constants::QUERY_PARAM_LANGUAGE_IN_HEADER ) ) {
return $this->request->getBool( Constants::QUERY_PARAM_LANGUAGE_IN_HEADER );
}
if (
(bool)$this->config->get( Constants::CONFIG_LANGUAGE_IN_HEADER_TREATMENT_AB_TEST ) &&
$this->user->isRegistered()
) {
if ( $this->request->getCheck( Constants::QUERY_PARAM_LANGUAGE_IN_HEADER ) ) {
return $this->request->getBool( Constants::QUERY_PARAM_LANGUAGE_IN_HEADER );
}
$id = null;
if ( $this->centralIdLookup ) {
$id = $this->centralIdLookup->centralIdFromLocalUser( $this->user );

View File

@ -234,6 +234,38 @@ class LanguageInHeaderTreatmentRequirementTest extends \MediaWikiUnitTestCase {
false,
'Even logged in users get old treatment when A/B test enabled and query param set to "0"'
],
[
// Is language enabled
[
'logged_in' => false,
'logged_out' => false,
],
// is A-B test enabled
false,
1,
// use central id lookup?
false,
// `languageinheader` query param
"1",
true,
'Users get new treatment when query param set to "1" regardless of state of A/B test or config flags'
],
[
// Is language enabled
[
'logged_in' => false,
'logged_out' => false,
],
// is A-B test enabled
false,
1,
// use central id lookup?
false,
// `languageinheader` query param
"0",
false,
'Users get old treatment when query param set to "0" regardless of state of A/B test or config flags'
],
];
}