Index: trunk/phase3/includes/specials/SpecialBlockList.php |
— | — | @@ -201,13 +201,6 @@ |
202 | 202 | protected $page; |
203 | 203 | |
204 | 204 | /** |
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 | | - /** |
212 | 205 | * @param $page SpecialPage |
213 | 206 | * @param $conds Array |
214 | 207 | */ |
— | — | @@ -313,12 +306,12 @@ |
314 | 307 | break; |
315 | 308 | |
316 | 309 | 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 | + } |
323 | 316 | break; |
324 | 317 | |
325 | 318 | case 'ipb_reason': |
— | — | @@ -358,12 +351,14 @@ |
359 | 352 | |
360 | 353 | function getQueryInfo() { |
361 | 354 | $info = array( |
362 | | - 'tables' => array( 'ipblocks' ), |
| 355 | + 'tables' => array( 'ipblocks', 'user' ), |
363 | 356 | 'fields' => array( |
364 | 357 | 'ipb_id', |
365 | 358 | 'ipb_address', |
366 | 359 | 'ipb_user', |
367 | 360 | 'ipb_by', |
| 361 | + 'ipb_by_text', |
| 362 | + 'user_name AS by_user_name', |
368 | 363 | 'ipb_reason', |
369 | 364 | 'ipb_timestamp', |
370 | 365 | 'ipb_auto', |
— | — | @@ -378,6 +373,7 @@ |
379 | 374 | 'ipb_allow_usertalk', |
380 | 375 | ), |
381 | 376 | 'conds' => $this->conds, |
| 377 | + 'join_conds' => array( 'user' => array( 'LEFT JOIN', 'user_id = ipb_by' ) ) |
382 | 378 | ); |
383 | 379 | |
384 | 380 | # Is the user allowed to see hidden blocks? |
— | — | @@ -428,9 +424,6 @@ |
429 | 425 | |
430 | 426 | $ua = UserArray::newFromIDs( $userids ); |
431 | 427 | foreach( $ua as $user ){ |
432 | | - /* @var $user User */ |
433 | | - $this->userNameCache[$user->getID()] = $user->getName(); |
434 | | - |
435 | 428 | $name = str_replace( ' ', '_', $user->getName() ); |
436 | 429 | $lb->add( NS_USER, $name ); |
437 | 430 | $lb->add( NS_USER_TALK, $name ); |