aboutsummaryrefslogtreecommitdiffstats
path: root/includes/user/Options
diff options
context:
space:
mode:
authorFunc <Funcer@outlook.com>2024-07-06 20:51:25 +0800
committerFunc <Funcer@outlook.com>2024-07-07 02:25:03 +0800
commit3e4278f480b83182db42a2ab7c343c723d2ae63f (patch)
treec998ae66768871939a7f3cf6a6d77c1370a1147d /includes/user/Options
parentfd50f4684cdaeb4358a7fd45f962c41a52e20577 (diff)
downloadmediawikicore-3e4278f480b83182db42a2ab7c343c723d2ae63f.tar.gz
mediawikicore-3e4278f480b83182db42a2ab7c343c723d2ae63f.zip
UserOptionsManager: Set the source for local exceptions with default values
Bug: T368595 Change-Id: I7b14cff095fe0f1eb9ff53762878f5801605ed6e
Diffstat (limited to 'includes/user/Options')
-rw-r--r--includes/user/Options/UserOptionsManager.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/includes/user/Options/UserOptionsManager.php b/includes/user/Options/UserOptionsManager.php
index 5b4646057e0b..f08dbf22b918 100644
--- a/includes/user/Options/UserOptionsManager.php
+++ b/includes/user/Options/UserOptionsManager.php
@@ -77,6 +77,8 @@ class UserOptionsManager extends UserOptionsLookup {
*/
public const GLOBAL_UPDATE = 'update';
+ private const LOCAL_STORE_KEY = 'local';
+
private ServiceOptions $serviceOptions;
private DefaultOptionsLookup $defaultOptionsLookup;
private LanguageConverterFactory $languageConverterFactory;
@@ -207,8 +209,8 @@ class UserOptionsManager extends UserOptionsLookup {
public function isOptionGlobal( UserIdentity $user, string $key ) {
$this->getOptions( $user );
- $source = $this->cache[ $this->getCacheKey( $user ) ]->sources[$key] ?? 'local';
- return $source !== 'local';
+ $source = $this->cache[ $this->getCacheKey( $user ) ]->sources[$key] ?? self::LOCAL_STORE_KEY;
+ return $source !== self::LOCAL_STORE_KEY;
}
/**
@@ -406,16 +408,16 @@ class UserOptionsManager extends UserOptionsLookup {
} else {
$valOrNull = (string)$value;
}
- $source = $cache->sources[$key] ?? 'local';
- if ( $source === 'local' ) {
- $updatesByStore['local'][$key] = $valOrNull;
+ $source = $cache->sources[$key] ?? self::LOCAL_STORE_KEY;
+ if ( $source === self::LOCAL_STORE_KEY ) {
+ $updatesByStore[self::LOCAL_STORE_KEY][$key] = $valOrNull;
} else {
$updateAction = $cache->globalUpdateActions[$key] ?? self::GLOBAL_IGNORE;
if ( $updateAction === self::GLOBAL_UPDATE ) {
$updatesByStore[$source][$key] = $valOrNull;
} elseif ( $updateAction === self::GLOBAL_OVERRIDE ) {
- $updatesByStore['local'][$key] = $valOrNull;
- $updatesByStore['local'][$key . self::LOCAL_EXCEPTION_SUFFIX] = '1';
+ $updatesByStore[self::LOCAL_STORE_KEY][$key] = $valOrNull;
+ $updatesByStore[self::LOCAL_STORE_KEY][$key . self::LOCAL_EXCEPTION_SUFFIX] = '1';
}
}
}
@@ -492,6 +494,8 @@ class UserOptionsManager extends UserOptionsLookup {
if ( str_ends_with( $name, self::LOCAL_EXCEPTION_SUFFIX ) && $value ) {
$baseName = substr( $name, 0, -strlen( self::LOCAL_EXCEPTION_SUFFIX ) );
if ( !isset( $options[$baseName] ) ) {
+ // T368595: The source should always be set to local for local exceptions
+ $cache->sources[$baseName] = self::LOCAL_STORE_KEY;
unset( $mergedOptions[$baseName] );
}
}
@@ -637,7 +641,9 @@ class UserOptionsManager extends UserOptionsLookup {
*/
private function getStores() {
if ( !$this->stores ) {
- $stores = [ 'local' => new LocalUserOptionsStore( $this->dbProvider ) ];
+ $stores = [
+ self::LOCAL_STORE_KEY => new LocalUserOptionsStore( $this->dbProvider )
+ ];
$specs = ExtensionRegistry::getInstance()
->getAttribute( 'UserOptionsStoreProviders' );
foreach ( $specs as $name => $spec ) {