https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113792

Revision: 113792
Author:   aaron
Date:     2012-03-14 01:42:14 +0000 (Wed, 14 Mar 2012)
Log Message:
-----------
(bug 32827) "[Regression] Block log for IP ranges not shown on Special:Block"

Modified Paths:
--------------
    trunk/phase3/includes/specials/SpecialBlock.php

Modified: trunk/phase3/includes/specials/SpecialBlock.php
===================================================================
--- trunk/phase3/includes/specials/SpecialBlock.php     2012-03-14 01:23:01 UTC 
(rev 113791)
+++ trunk/phase3/includes/specials/SpecialBlock.php     2012-03-14 01:42:14 UTC 
(rev 113792)
@@ -381,19 +381,19 @@
                        $this->getLanguage()->pipeList( $links )
                );
 
-               if( $this->target instanceof User ){
+               $userTitle = self::getTargetUserTitle( $this->target );
+               if( $userTitle ){
                        # Get relevant extracts from the block and suppression 
logs, if possible
-                       $userpage = $this->target->getUserPage();
                        $out = '';
 
                        LogEventsList::showLogExtract(
                                $out,
                                'block',
-                               $userpage,
+                               $userTitle,
                                '',
                                array(
                                        'lim' => 10,
-                                       'msgKey' => array( 'blocklog-showlog', 
$userpage->getText() ),
+                                       'msgKey' => array( 'blocklog-showlog', 
$userTitle->getText() ),
                                        'showIfEmpty' => false
                                )
                        );
@@ -404,12 +404,12 @@
                                LogEventsList::showLogExtract(
                                        $out,
                                        'suppress',
-                                       $userpage,
+                                       $userTitle,
                                        '',
                                        array(
                                                'lim' => 10,
                                                'conds' => array( 'log_action' 
=> array( 'block', 'reblock', 'unblock' ) ),
-                                               'msgKey' => array( 
'blocklog-showsuppresslog', $userpage->getText() ),
+                                               'msgKey' => array( 
'blocklog-showsuppresslog', $userTitle->getText() ),
                                                'showIfEmpty' => false
                                        )
                                );
@@ -422,6 +422,21 @@
        }
 
        /**
+        * Get a user page target for things like logs.
+        * This handles account and IP range targets.
+        * @param $target User|string
+        * @return Title|null
+        */
+       protected static function getTargetUserTitle( $target ) {
+               if( $target instanceof User ) {
+                       return $target->getUserPage();
+               } elseif ( IP::isIPAddress( $target ) ) {
+                       return Title::makeTitleSafe( NS_USER, $target );
+               }
+               return null;
+       }
+
+       /**
         * Determine the target of the block, and the type of target
         * TODO: should be in Block.php?
         * @param $par String subpage parameter passed to setup, or data value 
from


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to