MediaWiki 1.42.1
MediaWiki\Cache\UserCache Class Reference

Public Member Functions

 __construct (LoggerInterface $logger, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory)
 Uses dependency injection since 1.36.
 
 doQuery (array $userIds, $options=[], $caller='')
 Preloads user names for given list of users.
 
 getProp ( $userId, $prop)
 Get a property of a user based on their user ID.
 
 getUserName ( $userId, $ip)
 Get the name of a user or return $ip if the user ID is 0.
 

Static Public Member Functions

static singleton ()
 

Protected Member Functions

 queryNeeded ( $uid, $type, array $options)
 Check if a cache type is in $options and was not loaded for this user.
 

Protected Attributes

 $cache = []
 
 $typesCached = []
 

Detailed Description

Since
1.20

Definition at line 33 of file UserCache.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Cache\UserCache::__construct ( LoggerInterface $logger,
IConnectionProvider $dbProvider,
LinkBatchFactory $linkBatchFactory )

Uses dependency injection since 1.36.

Parameters
LoggerInterface$logger
IConnectionProvider$dbProvider
LinkBatchFactory$linkBatchFactory

Definition at line 60 of file UserCache.php.

Member Function Documentation

◆ doQuery()

MediaWiki\Cache\UserCache::doQuery ( array $userIds,
$options = [],
$caller = '' )

Preloads user names for given list of users.

Parameters
array$userIdsList of user IDs
array$optionsOption flags; include 'userpage' and 'usertalk'
string$callerThe calling method

Definition at line 110 of file UserCache.php.

References NS_USER, NS_USER_TALK, and MediaWiki\Cache\UserCache\queryNeeded().

Referenced by MediaWiki\Cache\UserCache\getProp().

◆ getProp()

MediaWiki\Cache\UserCache::getProp ( $userId,
$prop )

Get a property of a user based on their user ID.

Parameters
int$userId
string$propUser property
Returns
mixed|false The property or false if the user does not exist

Definition at line 77 of file UserCache.php.

References MediaWiki\Cache\UserCache\doQuery().

Referenced by MediaWiki\Cache\UserCache\getUserName().

◆ getUserName()

MediaWiki\Cache\UserCache::getUserName ( $userId,
$ip )

Get the name of a user or return $ip if the user ID is 0.

Parameters
int$userId
string$ip
Returns
string
Since
1.22

Definition at line 100 of file UserCache.php.

References MediaWiki\Cache\UserCache\getProp().

◆ queryNeeded()

MediaWiki\Cache\UserCache::queryNeeded ( $uid,
$type,
array $options )
protected

Check if a cache type is in $options and was not loaded for this user.

Parameters
int$uidUser ID
string$typeCache type
array$optionsRequested cache types
Returns
bool

Definition at line 175 of file UserCache.php.

Referenced by MediaWiki\Cache\UserCache\doQuery().

◆ singleton()

static MediaWiki\Cache\UserCache::singleton ( )
static
Returns
UserCache

Definition at line 49 of file UserCache.php.

References MediaWiki\MediaWikiServices\getInstance().

Referenced by MediaWiki\User\User\whoIs(), and MediaWiki\User\User\whoIsReal().

Member Data Documentation

◆ $cache

MediaWiki\Cache\UserCache::$cache = []
protected

Definition at line 34 of file UserCache.php.

◆ $typesCached

MediaWiki\Cache\UserCache::$typesCached = []
protected

Definition at line 35 of file UserCache.php.


The documentation for this class was generated from the following file: