r100254 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100253‎ | r100254 | r100255 >
Date:18:50, 19 October 2011
Author:aaron
Status:ok (Comments)
Tags:core 
Comment:
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) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialBlockList.php
@@ -201,13 +201,6 @@
202202 protected $page;
203203
204204 /**
205 - * Getting the user names from the userids stored in the ipb_by column can be
206 - * expensive, so we cache the data here.
207 - * @var Array of ID => Name
208 - */
209 - private $userNameCache;
210 -
211 - /**
212205 * @param $page SpecialPage
213206 * @param $conds Array
214207 */
@@ -313,12 +306,12 @@
314307 break;
315308
316309 case 'ipb_by':
317 - $username = array_key_exists( $value, $this->userNameCache )
318 - ? $this->userNameCache[$value]
319 - : User::newFromId( $value )->getName();
320 -
321 - $formatted = Linker::userLink( $value, $username );
322 - $formatted .= Linker::userToolLinks( $value, $username );
 310+ if ( isset( $row->by_user_name ) ) {
 311+ $formatted = Linker::userLink( $value, $row->by_user_name );
 312+ $formatted .= Linker::userToolLinks( $value, $row->by_user_name );
 313+ } else {
 314+ $formatted = htmlspecialchars( $row->ipb_by_text ); // foreign user?
 315+ }
323316 break;
324317
325318 case 'ipb_reason':
@@ -358,12 +351,14 @@
359352
360353 function getQueryInfo() {
361354 $info = array(
362 - 'tables' => array( 'ipblocks' ),
 355+ 'tables' => array( 'ipblocks', 'user' ),
363356 'fields' => array(
364357 'ipb_id',
365358 'ipb_address',
366359 'ipb_user',
367360 'ipb_by',
 361+ 'ipb_by_text',
 362+ 'user_name AS by_user_name',
368363 'ipb_reason',
369364 'ipb_timestamp',
370365 'ipb_auto',
@@ -378,6 +373,7 @@
379374 'ipb_allow_usertalk',
380375 ),
381376 'conds' => $this->conds,
 377+ 'join_conds' => array( 'user' => array( 'LEFT JOIN', 'user_id = ipb_by' ) )
382378 );
383379
384380 # Is the user allowed to see hidden blocks?
@@ -428,9 +424,6 @@
429425
430426 $ua = UserArray::newFromIDs( $userids );
431427 foreach( $ua as $user ){
432 - /* @var $user User */
433 - $this->userNameCache[$user->getID()] = $user->getName();
434 -
435428 $name = str_replace( ' ', '_', $user->getName() );
436429 $lb->add( NS_USER, $name );
437430 $lb->add( NS_USER_TALK, $name );

Sign-offs

UserFlagDate
Awjrichardsinspected21:07, 27 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99100FU r83909: restore preprocessing stage to cache link existence using LinkBatc...happy-melon13:25, 6 October 2011

Comments

#Comment by Duplicatebug (talk | contribs)   18:56, 21 October 2011

Why making the query expensiver? It was removed for api queries with bug 27611 to have it easy. Fix the RenameUser extension, when there are to many wrong values in the database (bug 23135).

Why not join ipb_user also against the user table?

#Comment by Happy-melon (talk | contribs)   08:26, 1 November 2011

This is not for RenameUser; it's for CentralAuth global-suppression blocks, where the blocking steward may not have an account on the wiki where the block is being registered. Cf r84534 CR.

#Comment by Aaron Schulz (talk | contribs)   08:46, 1 November 2011

Well, it's for both actually :)

Status & tagging log