MediaWiki fundraising/REL1_35
GenderCache Class Reference

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

Collaboration diagram for GenderCache:

Public Member Functions

 __construct (NamespaceInfo $nsInfo=null, ILoadBalancer $loadBalancer=null, UserOptionsLookup $userOptionsLookup=null)
 
 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 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)
 

Private Attributes

ILoadBalancer null $loadBalancer
 
NamespaceInfo $nsInfo
 
UserOptionsLookup $userOptionsLookup
 

Detailed Description

Caches user genders when needed to use correct namespace aliases.

Since
1.18

Definition at line 36 of file GenderCache.php.

Constructor & Destructor Documentation

◆ __construct()

GenderCache::__construct ( NamespaceInfo $nsInfo = null,
ILoadBalancer $loadBalancer = null,
UserOptionsLookup $userOptionsLookup = null )

Definition at line 51 of file GenderCache.php.

References $loadBalancer.

Member Function Documentation

◆ doLinkBatch()

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

Wrapper for doQuery that processes raw LinkBatch data.

Parameters
array$data
string$caller

Definition at line 123 of file GenderCache.php.

References doQuery().

◆ doQuery()

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

Preloads genders for given list of users.

Parameters
string[] | string$usersUsernames
string$callerThe calling method

Definition at line 161 of file GenderCache.php.

References $dbr, $default, $res, DB_REPLICA, and getDefault().

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

◆ doTitlesArray()

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

Wrapper for doQuery that processes a title array.

Since
1.20
Parameters
LinkTarget[]$titles
string$callerThe calling method

Definition at line 144 of file GenderCache.php.

References doQuery().

◆ getDefault()

GenderCache::getDefault ( )
protected

Returns the default gender option in this wiki.

Returns
string

Definition at line 75 of file GenderCache.php.

Referenced by doQuery(), and getGenderOf().

◆ getGenderOf()

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

Returns the gender for given username.

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

Definition at line 89 of file GenderCache.php.

References doQuery(), getDefault(), and wfDebug().

◆ normalizeUsername()

static GenderCache::normalizeUsername ( $username)
staticprivate

Definition at line 206 of file GenderCache.php.

◆ singleton()

static GenderCache::singleton ( )
static
See also
MediaWikiServices::getInstance()->getGenderCache()
Deprecated
in 1.28 (soft), 1.35 (hard)
Returns
GenderCache

Definition at line 66 of file GenderCache.php.

References wfDeprecated().

Member Data Documentation

◆ $cache

GenderCache::$cache = []
protected

Definition at line 37 of file GenderCache.php.

◆ $default

GenderCache::$default
protected

Definition at line 38 of file GenderCache.php.

Referenced by doQuery().

◆ $loadBalancer

ILoadBalancer null GenderCache::$loadBalancer
private

Definition at line 46 of file GenderCache.php.

Referenced by __construct().

◆ $misses

GenderCache::$misses = 0
protected

Definition at line 39 of file GenderCache.php.

◆ $missLimit

GenderCache::$missLimit = 1000
protected

Definition at line 40 of file GenderCache.php.

◆ $nsInfo

NamespaceInfo GenderCache::$nsInfo
private

Definition at line 43 of file GenderCache.php.

◆ $userOptionsLookup

UserOptionsLookup GenderCache::$userOptionsLookup
private

Definition at line 49 of file GenderCache.php.


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