jenkins-bot has submitted this change and it was merged.

Change subject: Do not unauthenticate if autocreation fails due to a race
......................................................................


Do not unauthenticate if autocreation fails due to a race

Bug: T70012
Change-Id: I523ee94744ac943ede78af59ab381b65ae26e672
(cherry-picked from commit c4c501d9bbcf44baf72efe7c0ee343d699fb76fd)
---
M includes/session/SessionManager.php
1 file changed, 15 insertions(+), 6 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/session/SessionManager.php 
b/includes/session/SessionManager.php
index 6e4f99c..caa36fa 100644
--- a/includes/session/SessionManager.php
+++ b/includes/session/SessionManager.php
@@ -474,12 +474,21 @@
                        $status = $user->addToDatabase();
                        if ( !$status->isOK() ) {
                                // @codeCoverageIgnoreStart
-                               $logger->error( __METHOD__ . ': failed with 
message ' . $status->getWikiText(),
-                                       array(
-                                               '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',
+                                               array(
+                                                       'username' => $userName,
+                                               ) );
+                               } else {
+                                       $logger->error( __METHOD__ . ': failed 
with message ' . $status->getWikiText(),
+                                               array(
+                                                       'username' => $userName,
+                                               ) );
+                               }
+                               $user->setId( $id );
+                               $user->loadFromId( User::READ_LATEST );
                                return false;
                                // @codeCoverageIgnoreEnd
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/272835
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I523ee94744ac943ede78af59ab381b65ae26e672
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.27.0-wmf.14
Gerrit-Owner: GergÅ‘ Tisza <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to