r90453 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90452‎ | r90453 | r90454 >
Date:10:04, 20 June 2011
Author:nikerabbit
Status:ok (Comments)
Tags:
Comment:
Proposed fix for bug 29450. Don't use the current user's gender for invalid users.
Any ideas how to write tests for this?
Modified paths:
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -272,24 +272,27 @@
273273 * @param $user string
274274 * @return
275275 */
276 - static function gender( $parser, $user ) {
 276+ static function gender( $parser, $username ) {
277277 wfProfileIn( __METHOD__ );
278278 $forms = array_slice( func_get_args(), 2);
279279
 280+ $username = trim( $username );
 281+
280282 // default
281283 $gender = User::getDefaultOption( 'gender' );
282284
283285 // allow prefix.
284 - $title = Title::newFromText( $user );
 286+ $title = Title::newFromText( $username );
285287
286 - if ( is_object( $title ) && $title->getNamespace() == NS_USER )
287 - $user = $title->getText();
 288+ if ( $title && $title->getNamespace() == NS_USER ) {
 289+ $username = $title->getText();
 290+ }
288291
289292 // check parameter, or use the ParserOptions if in interface message
290 - $user = User::newFromName( $user );
 293+ $user = User::newFromName( $username );
291294 if ( $user ) {
292295 $gender = $user->getOption( 'gender' );
293 - } elseif ( $parser->getOptions()->getInterfaceMessage() ) {
 296+ } elseif ( $username === '' && $parser->getOptions()->getInterfaceMessage() ) {
294297 $gender = $parser->getOptions()->getUser()->getOption( 'gender' );
295298 }
296299 $ret = $parser->getFunctionLang()->gender( $gender, $forms );

Follow-up revisions

RevisionCommit summaryAuthorDate
r90454Fu r90453. Updates commentsnikerabbit10:19, 20 June 2011

Comments

#Comment by MaxSem (talk | contribs)   10:17, 20 June 2011

You forgot to rename $user to $username in comments.

#Comment by Nikerabbit (talk | contribs)   10:19, 20 June 2011

poop

Status & tagging log