MediaWiki REL1_31
GenderCache Class Reference

Caches user genders when needed to use correct namespace aliases. More...

Public Member Functions

 doLinkBatch ( $data, $caller='')
 Wrapper for doQuery that processes raw LinkBatch data.
 
 doQuery ( $users, $caller='')
 Preloads genders for given list of users.
 
 doTitlesArray ( $titles, $caller='')
 Wrapper for doQuery that processes a title or string array.
 
 getGenderOf ( $username, $caller='')
 Returns the gender for given username.
 

Static Public Member Functions

static singleton ()
 

Protected Member Functions

 getDefault ()
 Returns the default gender option in this wiki.
 

Protected Attributes

 $cache = []
 
 $default
 
 $misses = 0
 
 $missLimit = 1000
 

Static Private Member Functions

static normalizeUsername ( $username)
 

Detailed Description

Caches user genders when needed to use correct namespace aliases.

Since
1.18

Definition at line 31 of file GenderCache.php.

Member Function Documentation

◆ doLinkBatch()

GenderCache::doLinkBatch ( $data,
$caller = '' )

Wrapper for doQuery that processes raw LinkBatch data.

Parameters
array$data
string$caller

Definition at line 97 of file GenderCache.php.

References $username, and doQuery().

◆ doQuery()

GenderCache::doQuery ( $users,
$caller = '' )

Preloads genders for given list of users.

Parameters
array | string$usersUsernames
string$callerThe calling method

Definition at line 139 of file GenderCache.php.

References $dbr, $default, $name, $res, $value, cache, DB_REPLICA, getDefault(), User\isValidUserName(), and wfGetDB().

Referenced by doLinkBatch(), doTitlesArray(), and getGenderOf().

◆ doTitlesArray()

GenderCache::doTitlesArray ( $titles,
$caller = '' )

Wrapper for doQuery that processes a title or string array.

Since
1.20
Parameters
array$titlesArray of Title objects or strings
string$callerThe calling method

Definition at line 118 of file GenderCache.php.

References $title, $titles, and doQuery().

◆ getDefault()

GenderCache::getDefault ( )
protected

Returns the default gender option in this wiki.

Returns
string

Definition at line 49 of file GenderCache.php.

References User\getDefaultOption().

Referenced by doQuery(), and getGenderOf().

◆ getGenderOf()

GenderCache::getGenderOf ( $username,
$caller = '' )

Returns the gender for given username.

Parameters
string | User$username
string$callerThe calling method
Returns
string

Definition at line 63 of file GenderCache.php.

References $username, $wgUser, cache, doQuery(), getDefault(), and wfDebug().

◆ normalizeUsername()

static GenderCache::normalizeUsername ( $username)
staticprivate

Definition at line 178 of file GenderCache.php.

References $username.

◆ singleton()

static GenderCache::singleton ( )
static
Deprecated
in 1.28 see MediaWikiServices::getInstance()->getGenderCache()
Returns
GenderCache

Definition at line 41 of file GenderCache.php.

Member Data Documentation

◆ $cache

GenderCache::$cache = []
protected

Definition at line 32 of file GenderCache.php.

◆ $default

GenderCache::$default
protected

Definition at line 33 of file GenderCache.php.

Referenced by doQuery().

◆ $misses

GenderCache::$misses = 0
protected

Definition at line 34 of file GenderCache.php.

◆ $missLimit

GenderCache::$missLimit = 1000
protected

Definition at line 35 of file GenderCache.php.


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