From: Gergő Tisza Date: Thu, 18 Feb 2016 02:10:31 +0000 (+0000) Subject: Do not unauthenticate if autocreation fails due to a race X-Git-Tag: 1.31.0-rc.0~7917^2 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=c4c501d9bbcf44baf72efe7c0ee343d699fb76fd;p=lhc%2Fweb%2Fwiklou.git Do not unauthenticate if autocreation fails due to a race Bug: T70012 Change-Id: I523ee94744ac943ede78af59ab381b65ae26e672 --- diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php index 5573ec7af3..e7a5e2ea49 100644 --- a/includes/session/SessionManager.php +++ b/includes/session/SessionManager.php @@ -475,12 +475,21 @@ final class SessionManager implements SessionManagerInterface { $status = $user->addToDatabase(); if ( !$status->isOK() ) { // @codeCoverageIgnoreStart - $logger->error( __METHOD__ . ': failed with message ' . $status->getWikiText(), - [ - 'username' => $userName, - ] ); - $user->setId( 0 ); - $user->loadFromId(); + // double-check for a race condition (T70012) + $id = User::idFromName( $user->getName(), User::READ_LATEST ); + if ( $id ) { + $logger->info( __METHOD__ . ': tried to autocreate existing user', + [ + 'username' => $userName, + ] ); + } else { + $logger->error( __METHOD__ . ': failed with message ' . $status->getWikiText(), + [ + 'username' => $userName, + ] ); + } + $user->setId( $id ); + $user->loadFromId( User::READ_LATEST ); return false; // @codeCoverageIgnoreEnd }