From: umherirrender Date: Sat, 7 Apr 2012 20:45:31 +0000 (+0200) Subject: GENDER should use the GenderCache X-Git-Tag: 1.31.0-rc.0~23960^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=dfe61f64af3d5d7f18abb4e5bbba7f0a76ea8439;p=lhc%2Fweb%2Fwiklou.git GENDER should use the GenderCache This reused the gender state of a user on a page. This is helpful for special pages which shows the group name, because the each group name used gender, which result in often use. Change-Id: I8e816f54aaa100c3333e84e19299fd194323341d --- diff --git a/includes/cache/GenderCache.php b/includes/cache/GenderCache.php index 342f8dba83..2cc1061742 100644 --- a/includes/cache/GenderCache.php +++ b/includes/cache/GenderCache.php @@ -37,13 +37,17 @@ class GenderCache { /** * Returns the gender for given username. - * @param $username String: username + * @param $username String or User: username * @param $caller String: the calling method * @return String */ public function getGenderOf( $username, $caller = '' ) { global $wgUser; + if( $username instanceof User ) { + $username = $username->getName(); + } + $username = strtr( $username, '_', ' ' ); if ( !isset( $this->cache[$username] ) ) { diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 35d03c4c28..8be99468aa 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -308,9 +308,9 @@ class CoreParserFunctions { // check parameter, or use the ParserOptions if in interface message $user = User::newFromName( $username ); if ( $user ) { - $gender = $user->getOption( 'gender' ); + $gender = GenderCache::singleton()->getGenderOf( $user, __METHOD__ ); } elseif ( $username === '' && $parser->getOptions()->getInterfaceMessage() ) { - $gender = $parser->getOptions()->getUser()->getOption( 'gender' ); + $gender = GenderCache::singleton()->getGenderOf( $parser->getOptions()->getUser(), __METHOD__ ); } $ret = $parser->getFunctionLang()->gender( $gender, $forms ); wfProfileOut( __METHOD__ );