Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/308916
Change subject: Cleanup rename/merge Job transaction ownership ...................................................................... Cleanup rename/merge Job transaction ownership Use the "run" method for $fname instead of __METHOD__. Change-Id: I9bfce94d17e14c65224e611a2ddcd3751604605c --- M includes/LocalRenameJob/LocalRenameUserJob.php M includes/LocalRenameJob/LocalUserMergeJob.php 2 files changed, 14 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth refs/changes/16/308916/1 diff --git a/includes/LocalRenameJob/LocalRenameUserJob.php b/includes/LocalRenameJob/LocalRenameUserJob.php index 91bd6bc..89f8eb5 100644 --- a/includes/LocalRenameJob/LocalRenameUserJob.php +++ b/includes/LocalRenameJob/LocalRenameUserJob.php @@ -36,8 +36,9 @@ $this->updateStatus( 'inprogress' ); // Make the status update visible to all other transactions immediately + $fnameTrxOwner = __CLASS__ . '::run'; // ownership delegated from run() $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); - $factory->commitMasterChanges( __METHOD__ ); + $factory->commitMasterChanges( $fnameTrxOwner ); 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 9cd2535..3551719 100755 --- a/includes/LocalRenameJob/LocalUserMergeJob.php +++ b/includes/LocalRenameJob/LocalUserMergeJob.php @@ -25,10 +25,19 @@ $this->updateStatus( 'inprogress' ); // Make the status update visible to all other transactions immediately + $fnameTrxOwner = __CLASS__ . '::run'; // ownership delegated from run() $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); - $factory->commitMasterChanges( __METHOD__ ); + $factory->commitMasterChanges( $fnameTrxOwner ); $toUser = $this->maybeCreateNewUser( $to ); + if ( $toUser instanceof Status ) { + $factory->rollbackMasterChanges( $fnameTrxOwner ); + $this->updateStatus( 'failed' ); + // Make the status update visible to all other transactions immediately + $factory->commitMasterChanges( $fnameTrxOwner ); + throw new RuntimeException( "autoCreateUser failed for '{$to}': " . + $toUser->getWikiText( null, null, 'en' ) ); + } $renamingUser = $this->getRenameUser(); foreach ( $from as $olduser ) { @@ -61,7 +70,7 @@ * then merge into it. * * @param string $newName - * @return User + * @return User|Status Returns status on failure * @throws Exception */ private function maybeCreateNewUser( $newName ) { @@ -73,12 +82,7 @@ $status = Status::wrap( CentralAuthUtils::autoCreateUser( $user ) ); if ( !$status->isGood() ) { - $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); - $factory->rollbackMasterChanges( __METHOD__ ); - $this->updateStatus( 'failed' ); - $factory->commitMasterChanges( __METHOD__ ); - throw new Exception( "autoCreateUser failed for $newName: " . - $status->getWikiText( null, null, 'en' ) ); + return $status; } return $user; -- To view, visit https://gerrit.wikimedia.org/r/308916 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9bfce94d17e14c65224e611a2ddcd3751604605c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CentralAuth Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits