wiki.techinc.nl/includes/user/Options/UserOptionsCacheEntry.php
Tim Starling cdc5178150 user: Introduce UserOptionsStore
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
2024-06-12 01:27:57 +00:00

46 lines
1.1 KiB
PHP

<?php
namespace MediaWiki\User\Options;
use IDBAccessObject;
/**
* @internal
*/
class UserOptionsCacheEntry {
/**
* @var array<string,mixed> Values modified by setOption(), queued for update
*/
public $modifiedValues = [];
/**
* @var array<string,string> The source name for each value in $originalValues
*/
public $sources = [];
/**
* @var array<string,string> The value of the $global parameter to setOption()
*/
public $globalUpdateActions = [];
/**
* @var array<string,string>|null Cached original user options with all the
* adjustments like time correction and hook changes applied. Ready to be
* returned. Null if the original values have not been loaded
*/
public $originalValues;
/** @var int|null Query flags used to retrieve options from database */
public $recency;
/**
* Determine if it's OK to use cached options values for a given user and query flags
*
* @param int $recency
* @return bool
*/
public function canUseCachedValues( $recency ) {
$recencyUsed = $this->recency ?? IDBAccessObject::READ_NONE;
return $recencyUsed >= $recency;
}
}