User::clearSharedCache: don't load the full user record for just the ID
authorOri Livneh <ori@wikimedia.org>
Tue, 19 May 2015 22:45:46 +0000 (15:45 -0700)
committerOri Livneh <ori@wikimedia.org>
Tue, 19 May 2015 22:45:46 +0000 (15:45 -0700)
Rather than call $this->load() unconditionally, get just the ID via
$this->getId(), potentially saving us a database lookup.

Change-Id: Ifa3b96956a1d66d3e877573ff01970758fad8790

includes/User.php

index 7902119..eb2a2dc 100644 (file)
@@ -2301,11 +2301,10 @@ class User implements IDBAccessObject {
         * Called implicitly from invalidateCache() and saveSettings().
         */
        public function clearSharedCache() {
-               $this->load();
-               if ( $this->mId ) {
+               $id = $this->getId();
+               if ( $id ) {
                        $cache = ObjectCache::getMainWANInstance();
-
-                       $cache->delete( wfMemcKey( 'user', 'id', $this->mId ) );
+                       $cache->delete( wfMemcKey( 'user', 'id', $id ) );
                }
        }