r54525 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54524‎ | r54525 | r54526 >
Date:16:23, 6 August 2009
Author:werdna
Status:ok
Tags:
Comment:
Move ID-Name cache to a static variable, so it can be added to externally.
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -214,6 +214,8 @@
215215 $mBlockreason, $mBlock, $mEffectiveGroups, $mBlockedGlobally,
216216 $mLocked, $mHideName, $mOptions;
217217 //@}
 218+
 219+ static $idCacheByName = array();
218220
219221 /**
220222 * Lightweight constructor for an anonymous user.
@@ -457,10 +459,8 @@
458460 return null;
459461 }
460462
461 - static $cache = array();
462 -
463 - if ( isset($cache[$name]) ) {
464 - return $cache[$name];
 463+ if ( isset(self::$idCacheByName[$name]) ) {
 464+ return self::$idCacheByName[$name];
465465 }
466466
467467 $dbr = wfGetDB( DB_SLAVE );
@@ -472,10 +472,10 @@
473473 $result = $s->user_id;
474474 }
475475
476 - $cache[$name] = $result;
 476+ self::$idCacheByName[$name] = $result;
477477
478 - if ( count($cache) > 1000 ) {
479 - $cache = array();
 478+ if ( count(self::$idCacheByName) > 1000 ) {
 479+ self::$idCacheByName = array();
480480 }
481481
482482 return $result;

Status & tagging log