Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
— | — | @@ -272,24 +272,27 @@ |
273 | 273 | * @param $user string |
274 | 274 | * @return |
275 | 275 | */ |
276 | | - static function gender( $parser, $user ) { |
| 276 | + static function gender( $parser, $username ) { |
277 | 277 | wfProfileIn( __METHOD__ ); |
278 | 278 | $forms = array_slice( func_get_args(), 2); |
279 | 279 | |
| 280 | + $username = trim( $username ); |
| 281 | + |
280 | 282 | // default |
281 | 283 | $gender = User::getDefaultOption( 'gender' ); |
282 | 284 | |
283 | 285 | // allow prefix. |
284 | | - $title = Title::newFromText( $user ); |
| 286 | + $title = Title::newFromText( $username ); |
285 | 287 | |
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 | + } |
288 | 291 | |
289 | 292 | // check parameter, or use the ParserOptions if in interface message |
290 | | - $user = User::newFromName( $user ); |
| 293 | + $user = User::newFromName( $username ); |
291 | 294 | if ( $user ) { |
292 | 295 | $gender = $user->getOption( 'gender' ); |
293 | | - } elseif ( $parser->getOptions()->getInterfaceMessage() ) { |
| 296 | + } elseif ( $username === '' && $parser->getOptions()->getInterfaceMessage() ) { |
294 | 297 | $gender = $parser->getOptions()->getUser()->getOption( 'gender' ); |
295 | 298 | } |
296 | 299 | $ret = $parser->getFunctionLang()->gender( $gender, $forms ); |