MediaWiki 1.42.0
MediaWiki\Cache\GenderCache Class Reference

Look up "gender" user preference. More...

Public Member Functions

 __construct (NamespaceInfo $nsInfo=null, IConnectionProvider $dbProvider=null, UserOptionsLookup $userOptionsLookup=null)
 
 doLinkBatch (array $data, $caller='')
 Wrapper for doQuery that processes raw LinkBatch data.
 
 doQuery ( $users, $caller='')
 Preload gender option for multiple user names.
 
 doTitlesArray ( $titles, $caller='')
 Wrapper for doQuery that processes a title array.
 
 getGenderOf ( $username, $caller='')
 Get the gender option for given username.
 

Protected Member Functions

 getDefault ()
 Get the default gender option on this wiki.
 

Protected Attributes

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

Detailed Description

Look up "gender" user preference.

This primarily used in MediaWiki\Title\MediaWikiTitleCodec for title formatting of pages in gendered namespace aliases, and in CoreParserFunctions for the {{gender:}} parser function.

Since
1.18

Definition at line 42 of file GenderCache.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Cache\GenderCache::__construct ( NamespaceInfo $nsInfo = null,
IConnectionProvider $dbProvider = null,
UserOptionsLookup $userOptionsLookup = null )

Definition at line 53 of file GenderCache.php.

References MediaWiki\MediaWikiServices\getInstance().

Member Function Documentation

◆ doLinkBatch()

MediaWiki\Cache\GenderCache::doLinkBatch ( array $data,
$caller = '' )

Wrapper for doQuery that processes raw LinkBatch data.

Parameters
array<int,array<string,mixed>>$data
string | null$caller

Definition at line 109 of file GenderCache.php.

References MediaWiki\Cache\GenderCache\doQuery().

◆ doQuery()

MediaWiki\Cache\GenderCache::doQuery ( $users,
$caller = '' )

Preload gender option for multiple user names.

Parameters
string[] | string$usersUsernames
string | null$callerCalling method for database profiling

Definition at line 142 of file GenderCache.php.

References MediaWiki\Cache\GenderCache\$default, and MediaWiki\Cache\GenderCache\getDefault().

Referenced by MediaWiki\Cache\GenderCache\doLinkBatch(), MediaWiki\Cache\GenderCache\doTitlesArray(), and MediaWiki\Cache\GenderCache\getGenderOf().

◆ doTitlesArray()

MediaWiki\Cache\GenderCache::doTitlesArray ( $titles,
$caller = '' )

Wrapper for doQuery that processes a title array.

Since
1.20
Parameters
LinkTarget[]$titles
string | null$callerCalling method for database profiling

Definition at line 126 of file GenderCache.php.

References MediaWiki\Cache\GenderCache\doQuery().

◆ getDefault()

MediaWiki\Cache\GenderCache::getDefault ( )
protected

Get the default gender option on this wiki.

Returns
string

Definition at line 68 of file GenderCache.php.

References MediaWiki\Cache\GenderCache\$default.

Referenced by MediaWiki\Cache\GenderCache\doQuery(), and MediaWiki\Cache\GenderCache\getGenderOf().

◆ getGenderOf()

MediaWiki\Cache\GenderCache::getGenderOf ( $username,
$caller = '' )

Get the gender option for given username.

Parameters
string | UserIdentity$username
string | null$callerCalling method for database profiling
Returns
string

Definition at line 80 of file GenderCache.php.

References MediaWiki\Cache\GenderCache\doQuery(), MediaWiki\Cache\GenderCache\getDefault(), getUser(), and wfDebug().

Member Data Documentation

◆ $cache

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

Definition at line 43 of file GenderCache.php.

◆ $default

MediaWiki\Cache\GenderCache::$default = null
protected

◆ $misses

MediaWiki\Cache\GenderCache::$misses = 0
protected

Definition at line 45 of file GenderCache.php.

◆ $missLimit

MediaWiki\Cache\GenderCache::$missLimit = 1000
protected

Definition at line 47 of file GenderCache.php.


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