Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/304684
Change subject: Make sure status updates in jobs commit/rollback all DBs
together
......................................................................
Make sure status updates in jobs commit/rollback all DBs together
All fixed call to undefined getWikiText() method in StatusValue.
Change-Id: Ide1ee9ff75e61caf794c1acc9736a576cbf3233c
---
M includes/GlobalRename/GlobalRenameUserStatus.php
M includes/LocalRenameJob/LocalRenameJob.php
M includes/LocalRenameJob/LocalRenameUserJob.php
M includes/LocalRenameJob/LocalUserMergeJob.php
4 files changed, 21 insertions(+), 15 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth
refs/changes/84/304684/1
diff --git a/includes/GlobalRename/GlobalRenameUserStatus.php
b/includes/GlobalRename/GlobalRenameUserStatus.php
index f307973..ecb6101 100644
--- a/includes/GlobalRename/GlobalRenameUserStatus.php
+++ b/includes/GlobalRename/GlobalRenameUserStatus.php
@@ -201,14 +201,4 @@
}
);
}
-
- /**
- * Commit status changes to the database
- */
- public function commitStatus() {
- $dbw = $this->getDB( DB_MASTER );
- if ( $dbw->trxLevel() ) {
- $dbw->commit( __METHOD__ );
- }
- }
}
diff --git a/includes/LocalRenameJob/LocalRenameJob.php
b/includes/LocalRenameJob/LocalRenameJob.php
index 31d29e8..0eb0c88 100644
--- a/includes/LocalRenameJob/LocalRenameJob.php
+++ b/includes/LocalRenameJob/LocalRenameJob.php
@@ -1,6 +1,7 @@
<?php
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
/**
* Base class for jobs that change a user's
@@ -41,9 +42,11 @@
$this->doRun();
$this->addTeardownCallback( [ $this, 'scheduleNextWiki'
] );
} catch ( Exception $e ) {
- // This will lock the user out of their account
- // until a sysadmin intervenes
+ // This will lock the user out of their account until a
sysadmin intervenes
+ $factory =
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+ $factory->rollbackMasterChanges( __METHOD__ );
$this->updateStatus( 'failed' );
+ $factory->commitMasterChanges( __METHOD__ );
throw $e;
}
@@ -101,7 +104,6 @@
protected function updateStatus( $status ) {
$this->renameuserStatus->setStatus( wfWikiID(), $status );
- $this->renameuserStatus->commitStatus();
}
protected function scheduleNextWiki() {
diff --git a/includes/LocalRenameJob/LocalRenameUserJob.php
b/includes/LocalRenameJob/LocalRenameUserJob.php
index 5d2a754..91bd6bc 100644
--- a/includes/LocalRenameJob/LocalRenameUserJob.php
+++ b/includes/LocalRenameJob/LocalRenameUserJob.php
@@ -1,5 +1,7 @@
<?php
+use \MediaWiki\MediaWikiServices;
+
/**
* Job class to rename a user locally
* This is intended to be run on each wiki individually
@@ -33,6 +35,9 @@
$to = $this->params['to'];
$this->updateStatus( 'inprogress' );
+ // Make the status update visible to all other transactions
immediately
+ $factory =
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+ $factory->commitMasterChanges( __METHOD__ );
if ( isset( $this->params['force'] ) && $this->params['force']
) {
// If we're dealing with an invalid username, load the
data ourselves to avoid
diff --git a/includes/LocalRenameJob/LocalUserMergeJob.php
b/includes/LocalRenameJob/LocalUserMergeJob.php
index 4f9732f..9cd2535 100755
--- a/includes/LocalRenameJob/LocalUserMergeJob.php
+++ b/includes/LocalRenameJob/LocalUserMergeJob.php
@@ -1,5 +1,7 @@
<?php
+use \MediaWiki\MediaWikiServices;
+
/**
* Job class to merge a user locally
* This is intended to be run on each wiki individually
@@ -22,6 +24,9 @@
$to = $this->params['to'];
$this->updateStatus( 'inprogress' );
+ // Make the status update visible to all other transactions
immediately
+ $factory =
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+ $factory->commitMasterChanges( __METHOD__ );
$toUser = $this->maybeCreateNewUser( $to );
@@ -66,10 +71,14 @@
return $user;
}
- $status = CentralAuthUtils::autoCreateUser( $user );
+ $status = Status::wrap( CentralAuthUtils::autoCreateUser( $user
) );
if ( !$status->isGood() ) {
+ $factory =
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+ $factory->rollbackMasterChanges( __METHOD__ );
$this->updateStatus( 'failed' );
- throw new Exception( "autoCreateUser failed for
$newName: " . $status->getWikiText( null, null, 'en' ) );
+ $factory->commitMasterChanges( __METHOD__ );
+ throw new Exception( "autoCreateUser failed for
$newName: " .
+ $status->getWikiText( null, null, 'en' ) );
}
return $user;
--
To view, visit https://gerrit.wikimedia.org/r/304684
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide1ee9ff75e61caf794c1acc9736a576cbf3233c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits