From a30ca127b7377f97cf6cae6b6e224cea3d53c6c9 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 18 Feb 2016 11:13:00 -0500 Subject: [PATCH] SessionManager: Autocreate should use READ_LATEST when necessary 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php index 5573ec7af3..f1ace2c24f 100644 --- a/includes/session/SessionManager.php +++ b/includes/session/SessionManager.php @@ -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; } -- 2.20.1