Made User::loadFromId() skip cache with READ_LATEST
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 30 Sep 2015 20:39:54 +0000 (13:39 -0700)
committerOri.livneh <ori@wikimedia.org>
Wed, 30 Sep 2015 21:53:25 +0000 (21:53 +0000)
* That flag is used for anti-dependencies and thus
  should never rely on cache

Bug: T95839
Change-Id: I4ffc8325e55588ef649b96e7b90bc95282f765a9

includes/User.php

index 4123eb2..4822f53 100644 (file)
@@ -385,10 +385,10 @@ class User implements IDBAccessObject {
                        return false;
                }
 
-               // Try cache (unless this needs to lock the DB).
+               // Try cache (unless this needs data from the master DB).
                // NOTE: if this thread called saveSettings(), the cache was cleared.
-               $locking = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING );
-               if ( $locking || !$this->loadFromCache() ) {
+               $latest = DBAccessObjectUtils::hasFlags( $flags, self::READ_LATEST );
+               if ( $latest || !$this->loadFromCache() ) {
                        wfDebug( "User: cache miss for user {$this->mId}\n" );
                        // Load from DB (make sure this thread sees its own changes)
                        if ( wfGetLB()->hasOrMadeRecentMasterChanges() ) {