Index: trunk/phase3/includes/User.php |
— | — | @@ -456,14 +456,29 @@ |
457 | 457 | # Illegal name |
458 | 458 | return null; |
459 | 459 | } |
| 460 | + |
| 461 | + static $cache = array(); |
| 462 | + |
| 463 | + if ( isset($cache[$name]) ) { |
| 464 | + return $cache[$name]; |
| 465 | + } |
| 466 | + |
460 | 467 | $dbr = wfGetDB( DB_SLAVE ); |
461 | 468 | $s = $dbr->selectRow( 'user', array( 'user_id' ), array( 'user_name' => $nt->getText() ), __METHOD__ ); |
462 | 469 | |
463 | 470 | if ( $s === false ) { |
464 | | - return 0; |
| 471 | + $result = 0; |
465 | 472 | } else { |
466 | | - return $s->user_id; |
| 473 | + $result = $s->user_id; |
467 | 474 | } |
| 475 | + |
| 476 | + $cache[$name] = $result; |
| 477 | + |
| 478 | + if ( count($cache) > 1000 ) { |
| 479 | + $cache = array(); |
| 480 | + } |
| 481 | + |
| 482 | + return $result; |
468 | 483 | } |
469 | 484 | |
470 | 485 | /** |