http://www.mediawiki.org/wiki/Special:Code/MediaWiki/100254

Revision: 100254
Author:   aaron
Date:     2011-10-19 18:50:34 +0000 (Wed, 19 Oct 2011)
Log Message:
-----------
Join ipb_by to user table to get the user name. If we can't find a user, 
fallback to ipb_by_text. This lets centralauth blocks have the blocking user be 
displayable again.

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

Modified: trunk/phase3/includes/specials/SpecialBlockList.php
===================================================================
--- trunk/phase3/includes/specials/SpecialBlockList.php 2011-10-19 18:46:54 UTC 
(rev 100253)
+++ trunk/phase3/includes/specials/SpecialBlockList.php 2011-10-19 18:50:34 UTC 
(rev 100254)
@@ -201,13 +201,6 @@
        protected $page;
 
        /**
-        * Getting the user names from the userids stored in the ipb_by column 
can be
-        * expensive, so we cache the data here.
-        * @var Array of ID => Name
-        */
-       private $userNameCache;
-
-       /**
         * @param $page SpecialPage
         * @param $conds Array
         */
@@ -313,12 +306,12 @@
                                break;
 
                        case 'ipb_by':
-                               $username = array_key_exists( $value, 
$this->userNameCache )
-                                       ? $this->userNameCache[$value]
-                                       : User::newFromId( $value )->getName();
-
-                               $formatted = Linker::userLink( $value, 
$username );
-                               $formatted .= Linker::userToolLinks( $value, 
$username );
+                               if ( isset( $row->by_user_name ) ) {
+                                       $formatted = Linker::userLink( $value, 
$row->by_user_name );
+                                       $formatted .= Linker::userToolLinks( 
$value, $row->by_user_name );
+                               } else {
+                                       $formatted = htmlspecialchars( 
$row->ipb_by_text ); // foreign user?
+                               }
                                break;
 
                        case 'ipb_reason':
@@ -358,12 +351,14 @@
 
        function getQueryInfo() {
                $info = array(
-                       'tables' => array( 'ipblocks' ),
+                       'tables' => array( 'ipblocks', 'user' ),
                        'fields' => array(
                                'ipb_id',
                                'ipb_address',
                                'ipb_user',
                                'ipb_by',
+                               'ipb_by_text',
+                               'user_name AS by_user_name',
                                'ipb_reason',
                                'ipb_timestamp',
                                'ipb_auto',
@@ -378,6 +373,7 @@
                                'ipb_allow_usertalk',
                        ),
                        'conds' => $this->conds,
+                       'join_conds' => array( 'user' => array( 'LEFT JOIN', 
'user_id = ipb_by' ) )
                );
 
                # Is the user allowed to see hidden blocks?
@@ -428,9 +424,6 @@
 
                $ua = UserArray::newFromIDs( $userids );
                foreach( $ua as $user ){
-                       /* @var $user User */
-                       $this->userNameCache[$user->getID()] = $user->getName();
-
                        $name = str_replace( ' ', '_', $user->getName() );
                        $lb->add( NS_USER, $name );
                        $lb->add( NS_USER_TALK, $name );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to