Index: trunk/phase3/includes/specials/SpecialBlock.php |
— | — | @@ -381,19 +381,19 @@ |
382 | 382 | $this->getLanguage()->pipeList( $links ) |
383 | 383 | ); |
384 | 384 | |
385 | | - if( $this->target instanceof User ){ |
| 385 | + $userTitle = self::getTargetUserTitle( $this->target ); |
| 386 | + if( $userTitle ){ |
386 | 387 | # Get relevant extracts from the block and suppression logs, if possible |
387 | | - $userpage = $this->target->getUserPage(); |
388 | 388 | $out = ''; |
389 | 389 | |
390 | 390 | LogEventsList::showLogExtract( |
391 | 391 | $out, |
392 | 392 | 'block', |
393 | | - $userpage, |
| 393 | + $userTitle, |
394 | 394 | '', |
395 | 395 | array( |
396 | 396 | 'lim' => 10, |
397 | | - 'msgKey' => array( 'blocklog-showlog', $userpage->getText() ), |
| 397 | + 'msgKey' => array( 'blocklog-showlog', $userTitle->getText() ), |
398 | 398 | 'showIfEmpty' => false |
399 | 399 | ) |
400 | 400 | ); |
— | — | @@ -404,12 +404,12 @@ |
405 | 405 | LogEventsList::showLogExtract( |
406 | 406 | $out, |
407 | 407 | 'suppress', |
408 | | - $userpage, |
| 408 | + $userTitle, |
409 | 409 | '', |
410 | 410 | array( |
411 | 411 | 'lim' => 10, |
412 | 412 | 'conds' => array( 'log_action' => array( 'block', 'reblock', 'unblock' ) ), |
413 | | - 'msgKey' => array( 'blocklog-showsuppresslog', $userpage->getText() ), |
| 413 | + 'msgKey' => array( 'blocklog-showsuppresslog', $userTitle->getText() ), |
414 | 414 | 'showIfEmpty' => false |
415 | 415 | ) |
416 | 416 | ); |
— | — | @@ -422,6 +422,21 @@ |
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
| 426 | + * Get a user page target for things like logs. |
| 427 | + * This handles account and IP range targets. |
| 428 | + * @param $target User|string |
| 429 | + * @return Title|null |
| 430 | + */ |
| 431 | + protected static function getTargetUserTitle( $target ) { |
| 432 | + if( $target instanceof User ) { |
| 433 | + return $target->getUserPage(); |
| 434 | + } elseif ( IP::isIPAddress( $target ) ) { |
| 435 | + return Title::makeTitleSafe( NS_USER, $target ); |
| 436 | + } |
| 437 | + return null; |
| 438 | + } |
| 439 | + |
| 440 | + /** |
426 | 441 | * Determine the target of the block, and the type of target |
427 | 442 | * TODO: should be in Block.php? |
428 | 443 | * @param $par String subpage parameter passed to setup, or data value from |