Drop the Vector.Config service

It didn't vary by the skin version as documented in the Constants class,
and merely another instance of GlobalVarConfig.

Change-Id: I0acd0366a241e04bb79f6aae5dc52284dfa578df
This commit is contained in:
Func 2022-04-05 21:54:23 +08:00
parent a0b1b5b056
commit b61a92f052
6 changed files with 10 additions and 40 deletions

View File

@ -11,13 +11,13 @@ use FatalError;
*/
final class Constants {
/**
* This is tightly coupled to the ConfigRegistry field in skin.json.
* This is tightly coupled to the ValidSkinNames field in skin.json.
* @var string
*/
public const SKIN_NAME_MODERN = 'vector-2022';
/**
* This is tightly coupled to the ConfigRegistry field in skin.json.
* This is tightly coupled to the ValidSkinNames field in skin.json.
* @var string
*/
public const SKIN_NAME_LEGACY = 'vector';
@ -33,11 +33,6 @@ final class Constants {
*/
public const SKIN_VERSION_LATEST = '2';
/**
* @var string
*/
public const SERVICE_CONFIG = 'Vector.Config';
/**
* @var string
*/

View File

@ -448,7 +448,8 @@ class Hooks {
* @param bool $isAutoCreated
*/
public static function onLocalUserCreated( User $user, $isAutoCreated ) {
$default = self::getConfig( Constants::CONFIG_KEY_DEFAULT_SKIN_VERSION_FOR_NEW_ACCOUNTS );
$config = MediaWikiServices::getInstance()->getMainConfig();
$default = $config->get( Constants::CONFIG_KEY_DEFAULT_SKIN_VERSION_FOR_NEW_ACCOUNTS );
if ( $default ) {
$optionsManager = MediaWikiServices::getInstance()->getUserOptionsManager();
$optionsManager->setOption(
@ -651,30 +652,12 @@ class Hooks {
if ( $user->isRegistered() && self::isSkinVersionLegacy( $skinName ) ) {
$vars[ 'wgVectorDisableSidebarPersistence' ] =
self::getConfig(
$out->getConfig()->get(
Constants::CONFIG_KEY_DISABLE_SIDEBAR_PERSISTENCE
);
}
}
/**
* Get a configuration variable.
*
* @param string $name Name of configuration option.
* @return mixed Value configured.
* @throws \ConfigException
*/
private static function getConfig( $name ) {
return self::getServiceConfig()->get( $name );
}
/**
* @return \Config
*/
private static function getServiceConfig() {
return MediaWikiServices::getInstance()->getService( Constants::SERVICE_CONFIG );
}
/**
* Gets whether the current skin version is the legacy version.
* Should mirror SkinVector::isLegacy

View File

@ -29,9 +29,6 @@ use Vector\FeatureManagement\Requirements\DynamicConfigRequirement;
use Vector\FeatureManagement\Requirements\OverridableConfigRequirement;
return [
Constants::SERVICE_CONFIG => static function ( MediaWikiServices $services ) {
return $services->getService( 'ConfigFactory' )->makeConfig( Constants::SKIN_NAME_LEGACY );
},
Constants::SERVICE_FEATURE_MANAGER => static function ( MediaWikiServices $services ) {
$featureManager = new FeatureManager();

View File

@ -18,7 +18,7 @@ final class VectorServices {
* Gets the feature manager service.
*
* Per its definition in ServiceWiring.php, the feature manager service is bound to the global
* request and user objects and to the _Vector.Config_ service.
* request and user objects.
*
* @return FeatureManager
*/

View File

@ -128,9 +128,6 @@
"AutoloadNamespaces": {
"Vector\\": "includes/"
},
"ConfigRegistry": {
"vector": "GlobalVarConfig::newInstance"
},
"Hooks": {
"ResourceLoaderSiteModulePages": "Vector\\Hooks::onResourceLoaderSiteModulePages",
"ResourceLoaderSiteStylesModulePages": "Vector\\Hooks::onResourceLoaderSiteStylesModulePages",

View File

@ -322,10 +322,9 @@ class VectorHooksTest extends MediaWikiIntegrationTestCase {
* @covers ::onLocalUserCreated
*/
public function testOnLocalUserCreatedLegacy() {
$config = new HashConfig( [
'VectorDefaultSkinVersionForNewAccounts' => Constants::SKIN_VERSION_LEGACY,
$this->setMwGlobals( [
'wgVectorDefaultSkinVersionForNewAccounts' => Constants::SKIN_VERSION_LEGACY,
] );
$this->setService( 'Vector.Config', $config );
$user = $this->createMock( User::class );
$userOptionsManager = $this->createMock( UserOptionsManager::class );
@ -341,10 +340,9 @@ class VectorHooksTest extends MediaWikiIntegrationTestCase {
* @covers ::onLocalUserCreated
*/
public function testOnLocalUserCreatedLatest() {
$config = new HashConfig( [
'VectorDefaultSkinVersionForNewAccounts' => Constants::SKIN_VERSION_LATEST,
$this->setMwGlobals( [
'wgVectorDefaultSkinVersionForNewAccounts' => Constants::SKIN_VERSION_LATEST,
] );
$this->setService( 'Vector.Config', $config );
$user = $this->createMock( User::class );
$userOptionsManager = $this->createMock( UserOptionsManager::class );