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

Change subject: Remove DB begin()/commit() from adminSetHidden()
......................................................................


Remove DB begin()/commit() from adminSetHidden()

* This use the same transaction just like the other methods
  called in adminLockHide().
* Push the suppression jobs at a safer time (closer to COMMIT)
  were less things can go wrong.

Bug: T120791
Change-Id: I1630230caae1a23babcff66d90dfc5425c591847
---
M includes/CentralAuthUser.php
1 file changed, 6 insertions(+), 4 deletions(-)

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



diff --git a/includes/CentralAuthUser.php b/includes/CentralAuthUser.php
index 49d8b74..636858e 100644
--- a/includes/CentralAuthUser.php
+++ b/includes/CentralAuthUser.php
@@ -1401,14 +1401,11 @@
         */
        function adminSetHidden( $level ) {
                $dbw = CentralAuthUtils::getCentralDB();
-               $dbw->begin();
                $dbw->update( 'globaluser', array( 'gu_hidden' => $level ),
                        array( 'gu_name' => $this->mName ), __METHOD__ );
                if ( !$dbw->affectedRows() ) {
-                       $dbw->commit();
                        return Status::newFatal( 
'centralauth-admin-unhide-nonexistent', $this->mName );
                }
-               $dbw->commit();
 
                $this->invalidateCache();
 
@@ -1585,7 +1582,12 @@
                                        Title::makeTitleSafe( NS_USER, 
$this->getName() ),
                                        $jobParams );
                        }
-                       JobQueueGroup::singleton()->push( $jobs );
+                       // Push the jobs right before COMMIT (which is likely 
to succeed).
+                       // If the job push fails, then the transaction will 
roll back.
+                       $dbw = self::getCentralDB();
+                       $dbw->onTransactionPreCommitOrIdle( function () use ( 
$jobs ) {
+                               JobQueueGroup::singleton()->push( $jobs );
+                       } );
                }
        }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1630230caae1a23babcff66d90dfc5425c591847
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to