Move ID-Name cache to a static variable, so it can be added to externally.
authorAndrew Garrett <werdna@users.mediawiki.org>
Thu, 6 Aug 2009 16:23:23 +0000 (16:23 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Thu, 6 Aug 2009 16:23:23 +0000 (16:23 +0000)
includes/User.php

index 1a5c3b5..a1ef09c 100644 (file)
@@ -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;