Merge "Fix bug in SkinVersionLookup" into wmf/1.38.0-wmf.18

This commit is contained in:
jenkins-bot 2022-01-26 00:39:54 +00:00 committed by Gerrit Code Review
commit c01c0cdcdc
2 changed files with 35 additions and 11 deletions

View File

@ -108,17 +108,21 @@ final class SkinVersionLookup {
*/
public function getVersion(): string {
$migrationMode = $this->config->get( 'VectorSkinMigrationMode' );
$useSkin = $this->request->getVal(
Constants::QUERY_PARAM_SKIN
);
// In migration mode, the useskin parameter is the source of truth.
if ( $migrationMode ) {
$useSkin = $this->request->getVal(
Constants::QUERY_PARAM_SKIN
);
if ( $useSkin ) {
return $useSkin === Constants::SKIN_NAME_LEGACY ?
Constants::SKIN_VERSION_LEGACY :
Constants::SKIN_VERSION_LATEST;
}
}
// [[phab:T299971]]
if ( $useSkin === Constants::SKIN_NAME_MODERN ) {
return Constants::SKIN_VERSION_LATEST;
}
// If skin key is not vector, then version should be considered legacy.

View File

@ -36,8 +36,13 @@ class SkinVersionLookupTest extends \MediaWikiIntegrationTestCase {
$request = $this->getMockBuilder( \WebRequest::class )->getMock();
$request
->method( 'getVal' )
->with( $this->anything(), 'beta' )
->willReturn( 'alpha' );
->willReturnCallback( static function ( $key ) {
if ( $key === Constants::QUERY_PARAM_SKIN ) {
return null;
} else {
return 'alpha';
}
} );
$user = $this->createMock( \User::class );
$user
@ -76,8 +81,13 @@ class SkinVersionLookupTest extends \MediaWikiIntegrationTestCase {
$request = $this->getMockBuilder( \WebRequest::class )->getMock();
$request
->method( 'getVal' )
->with( $this->anything(), 'beta' )
->willReturn( 'beta' );
->willReturnCallback( static function ( $key ) {
if ( $key === Constants::QUERY_PARAM_SKIN ) {
return null;
} else {
return 'beta';
}
} );
$user = $this->createMock( \User::class );
$user
@ -116,8 +126,13 @@ class SkinVersionLookupTest extends \MediaWikiIntegrationTestCase {
$request = $this->getMockBuilder( \WebRequest::class )->getMock();
$request
->method( 'getVal' )
->with( $this->anything(), '1' )
->willReturn( '1' );
->willReturnCallback( static function ( $key ) {
if ( $key === Constants::QUERY_PARAM_SKIN ) {
return null;
} else {
return '1';
}
} );
$user = $this->createMock( \User::class );
$user
@ -296,8 +311,13 @@ class SkinVersionLookupTest extends \MediaWikiIntegrationTestCase {
$request = $this->getMockBuilder( \WebRequest::class )->getMock();
$request
->method( 'getVal' )
->with( $this->anything(), '2' )
->willReturn( '2' );
->willReturnCallback( static function ( $key ) {
if ( $key === Constants::QUERY_PARAM_SKIN ) {
return null;
} else {
return '2';
}
} );
$user = $this->createMock( \User::class );
$user