SessionManager: Autocreate should use READ_LATEST when necessary
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 18 Feb 2016 16:13:00 +0000 (11:13 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Thu, 18 Feb 2016 16:13:33 +0000 (11:13 -0500)
If we failed to fetch the user ID using the default flags but succeeded
with READ_LATEST, we should also be passing READ_LATEST to
$user->loadFromId().

Change-Id: If8fc332810c2703773a153760ad076c398a84e4e

includes/session/SessionManager.php

index 5573ec7..f1ace2c 100644 (file)
@@ -358,19 +358,21 @@ final class SessionManager implements SessionManagerInterface {
 
                // Try the local user from the slave DB
                $localId = User::idFromName( $user->getName() );
+               $flags = 0;
 
                // Fetch the user ID from the master, so that we don't try to create the user
                // when they already exist, due to replication lag
                // @codeCoverageIgnoreStart
                if ( !$localId && wfGetLB()->getReaderIndex() != 0 ) {
                        $localId = User::idFromName( $user->getName(), User::READ_LATEST );
+                       $flags = User::READ_LATEST;
                }
                // @codeCoverageIgnoreEnd
 
                if ( $localId ) {
                        // User exists after all.
                        $user->setId( $localId );
-                       $user->loadFromId();
+                       $user->loadFromId( $flags );
                        return false;
                }