MediaWiki REL1_34
UserCache Class Reference

Public Member Functions

 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

 __construct ()
 
 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 27 of file UserCache.php.

Constructor & Destructor Documentation

◆ __construct()

UserCache::__construct ( )
protected

Definition at line 43 of file UserCache.php.

Member Function Documentation

◆ doQuery()

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 80 of file UserCache.php.

References $dbr, $res, DB_REPLICA, NS_USER, NS_USER_TALK, queryNeeded(), and wfGetDB().

Referenced by getProp().

◆ getProp()

UserCache::getProp (   $userId,
  $prop 
)

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

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

Definition at line 53 of file UserCache.php.

References doQuery(), and wfDebug().

Referenced by getUserName().

◆ getUserName()

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 70 of file UserCache.php.

References getProp().

◆ queryNeeded()

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 146 of file UserCache.php.

References $type.

Referenced by doQuery().

◆ singleton()

static UserCache::singleton ( )
static

Member Data Documentation

◆ $cache

UserCache::$cache = []
protected

Definition at line 28 of file UserCache.php.

◆ $typesCached

UserCache::$typesCached = []
protected

Definition at line 29 of file UserCache.php.


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