From 5e4a0958b4117c18dd0d0db5af4a49a2d92295d5 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Thu, 6 Aug 2009 16:23:23 +0000 Subject: [PATCH] Move ID-Name cache to a static variable, so it can be added to externally. --- includes/User.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/User.php b/includes/User.php index 1a5c3b5e65..a1ef09ccbf 100644 --- a/includes/User.php +++ b/includes/User.php @@ -214,6 +214,8 @@ class User { $mBlockreason, $mBlock, $mEffectiveGroups, $mBlockedGlobally, $mLocked, $mHideName, $mOptions; //@} + + static $idCacheByName = array(); /** * Lightweight constructor for an anonymous user. @@ -457,10 +459,8 @@ class User { return null; } - static $cache = array(); - - if ( isset($cache[$name]) ) { - return $cache[$name]; + if ( isset(self::$idCacheByName[$name]) ) { + return self::$idCacheByName[$name]; } $dbr = wfGetDB( DB_SLAVE ); @@ -472,10 +472,10 @@ class User { $result = $s->user_id; } - $cache[$name] = $result; + self::$idCacheByName[$name] = $result; - if ( count($cache) > 1000 ) { - $cache = array(); + if ( count(self::$idCacheByName) > 1000 ) { + self::$idCacheByName = array(); } return $result; -- 2.20.1