From 3d1894573048d6e508e190ab15ca5f9856752578 Mon Sep 17 00:00:00 2001
From: Andreas Fink <af@andreasfink.com>
Date: Wed, 26 Oct 2016 16:59:59 +0200
Subject: [PATCH] Try to work around issue #3 /
 https://phabricator.wikimedia.org/T95839

---
 AuthRemoteuser.body.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/AuthRemoteuser.body.php b/AuthRemoteuser.body.php
index 1c63977..9635a0d 100644
--- a/AuthRemoteuser.body.php
+++ b/AuthRemoteuser.body.php
@@ -124,6 +124,13 @@ class AuthRemoteuser extends MediaWiki\Session\ImmutableSessionProviderWithCooki
         if (Hooks::run("AuthRemoteUserInitUser",
             array($user, true))
         ) {
+            // Check if above hook or some other effect (e.g.: https://phabricator.wikimedia.org/T95839 )
+            // already created a user in the db. If so, reuse that one.
+            $userFromDb = $user->getInstanceForUpdate();
+            if (null !== $userFromDb) {
+                $user = $user->getInstanceForUpdate();
+            }
+
             $this->setRealName($user);
 
             $this->setEmail($user, $username);
-- 
GitLab