Refactoring: * Break out the database access part of UserOptionsManager to a separate class hierarchy implementing interface UserOptionsStore. It's basically a key/key/string-value store, very simple. The complex parts of user options storage remain in UserOptionsManager. * Bundle the UserOptionsManager caches into a per-user cache object. I was adding a couple more and it was getting tedious. Start integrating GlobalPreferences with UserOptionsManager: * Have an array of stores. There's always a local store, and extensions can add stores via an attribute. * Add $global parameter to UserOptionsManager::setOption(), allowing this method to update or override global options. * Rename loadOptionsFromDb to loadOptionsFromStore. * Move the local override feature from GlobalPreferences to core. Bug: T323076 Change-Id: Ib3623b723557c819bc0ffdf21a4ffcb070eb298b
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\User\Options;
|
|
|
|
use MediaWiki\User\UserIdentity;
|
|
|
|
/**
|
|
* @since 1.43
|
|
* @stable to implement
|
|
*/
|
|
interface UserOptionsStore {
|
|
/**
|
|
* Fetch all options for a given user from the store.
|
|
*
|
|
* Note that OptionsStore does not handle fallback to default. Options are
|
|
* either present or absent.
|
|
*
|
|
* @param UserIdentity $user A user with a non-zero ID
|
|
* @param int $recency a bit field composed of READ_XXX flags
|
|
* @return array<string,string>
|
|
*/
|
|
public function fetch( UserIdentity $user, int $recency );
|
|
|
|
/**
|
|
* Process a batch of option updates.
|
|
*
|
|
* The store may assume that fetch() was previously called with a recency
|
|
* sufficient to provide reference values for a differential update. It is
|
|
* the caller's responsibility to manage recency.
|
|
*
|
|
* Note that OptionsStore does not have a concept of defaults. The store is
|
|
* not required to check whether the value matches the default.
|
|
*
|
|
* @param UserIdentity $user A user with a non-zero ID
|
|
* @param array<string,string|null> $updates A map of option names to new
|
|
* values. If the value is null, the key should be deleted from the store
|
|
* and subsequently not returned from fetch(). Absent keys should be left
|
|
* unchanged.
|
|
* @return bool Whether any change was made
|
|
*/
|
|
public function store( UserIdentity $user, array $updates );
|
|
}
|