X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fcache%2FGenderCache.php;h=63e7bfd7466c2704629b37e9819fb83f6788e147;hb=1bd2974bbe8f972681717fbaa553d9099efa2f46;hp=a933527a888faf16b64a2e46c55d34192819cc7e;hpb=123d4122c84f4078de080046a1d2a4981dcdf4d7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/GenderCache.php b/includes/cache/GenderCache.php index a933527a88..63e7bfd746 100644 --- a/includes/cache/GenderCache.php +++ b/includes/cache/GenderCache.php @@ -41,27 +41,30 @@ class GenderCache { if ( $that === null ) { $that = new self(); } + return $that; } - protected function __construct() {} + protected function __construct() { + } /** * Returns the default gender option in this wiki. - * @return String + * @return string */ protected function getDefault() { if ( $this->default === null ) { $this->default = User::getDefaultOption( 'gender' ); } + return $this->default; } /** * Returns the gender for given username. - * @param string $username or User: username - * @param string $caller the calling method - * @return String + * @param string|User $username Username + * @param string $caller The calling method + * @return string */ public function getGenderOf( $username, $caller = '' ) { global $wgUser; @@ -77,8 +80,8 @@ class GenderCache { $this->misses++; wfDebug( __METHOD__ . ": too many misses, returning default onwards\n" ); } - return $this->getDefault(); + return $this->getDefault(); } else { $this->misses++; $this->doQuery( $username, $caller ); @@ -94,8 +97,8 @@ class GenderCache { /** * Wrapper for doQuery that processes raw LinkBatch data. * - * @param $data - * @param $caller + * @param array $data + * @param string $caller */ public function doLinkBatch( $data, $caller = '' ) { $users = array(); @@ -115,8 +118,8 @@ class GenderCache { * Wrapper for doQuery that processes a title or string array. * * @since 1.20 - * @param $titles List: array of Title objects or strings - * @param string $caller the calling method + * @param array $titles Array of Title objects or strings + * @param string $caller The calling method */ public function doTitlesArray( $titles, $caller = '' ) { $users = array(); @@ -136,8 +139,8 @@ class GenderCache { /** * Preloads genders for given list of users. - * @param $users List|String: usernames - * @param string $caller the calling method + * @param array|string $users Usernames + * @param string $caller The calling method */ public function doQuery( $users, $caller = '' ) { $default = $this->getDefault(); @@ -184,6 +187,7 @@ class GenderCache { if ( $indexSlash !== false ) { $username = substr( $username, 0, $indexSlash ); } + // normalize underscore/spaces return strtr( $username, '_', ' ' ); }