User: Bypass repeatable-read when creating an actor_id
[lhc/web/wiklou.git] / includes / user / User.php
index 40511cf..335e570 100644 (file)
@@ -2547,8 +2547,14 @@ class User implements IDBAccessObject, UserIdentity {
                                        $this->mActorId = (int)$dbw->insertId();
                                } else {
                                        // Outdated cache?
-                                       list( , $options ) = DBAccessObjectUtils::getDBOptions( $this->queryFlagsUsed );
-                                       $this->mActorId = (int)$dbw->selectField( 'actor', 'actor_id', $q, __METHOD__, $options );
+                                       // Use LOCK IN SHARE MODE to bypass any MySQL REPEATABLE-READ snapshot.
+                                       $this->mActorId = (int)$dbw->selectField(
+                                               'actor',
+                                               'actor_id',
+                                               $q,
+                                               __METHOD__,
+                                               [ 'LOCK IN SHARE MODE' ]
+                                       );
                                        if ( !$this->mActorId ) {
                                                throw new CannotCreateActorException(
                                                        "Cannot create actor ID for user_id={$this->getId()} user_name={$this->getName()}"