Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/306324
Change subject: [WIP] Add shouldAbort() method to DataUpdate updates ...................................................................... [WIP] Add shouldAbort() method to DataUpdate updates Change-Id: Iefedef667234e64c0fd980cca5596488b4290cde --- M includes/deferred/DataUpdate.php M includes/deferred/SqlDataUpdate.php 2 files changed, 24 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/24/306324/1 diff --git a/includes/deferred/DataUpdate.php b/includes/deferred/DataUpdate.php index 281ac24..30f8f9f 100644 --- a/includes/deferred/DataUpdate.php +++ b/includes/deferred/DataUpdate.php @@ -37,6 +37,10 @@ // noop } + public function shouldAbort() { + return false; + } + /** * @param mixed $ticket Result of getEmptyTransactionTicket() * @since 1.28 diff --git a/includes/deferred/SqlDataUpdate.php b/includes/deferred/SqlDataUpdate.php index ff06915..d927378 100644 --- a/includes/deferred/SqlDataUpdate.php +++ b/includes/deferred/SqlDataUpdate.php @@ -20,6 +20,7 @@ * * @file */ +use MediaWiki\MediaWikiServices; /** * Abstract base class for update jobs that put some secondary data extracted @@ -43,6 +44,9 @@ /** @var bool Whether this update should be wrapped in a transaction */ protected $mUseTransaction; + /** @var bool Whether the parent changes were rolled back */ + protected $abort = false; + /** * Constructor * @@ -53,12 +57,27 @@ public function __construct( $withTransaction = true ) { parent::__construct(); - $this->mDb = wfGetLB()->getLazyConnectionRef( DB_MASTER ); + $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); + $dbw = $lb->getAnyOpenConnection( DB_MASTER ); + if ( $dbw ) { + $dbw->onTransactionResolution( function ( $trigger ) { + if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) { + $this->abort = true; + } + } ); + $this->mDb = $dbw; + } else { + $this->mDb = $lb->getLazyConnectionRef( DB_MASTER ); + } $this->mWithTransaction = $withTransaction; $this->mHasTransaction = false; } + public function shouldAbort() { + return $this->abort; + } + /** * Begin a database transaction, if $withTransaction was given as true in * the constructor for this SqlDataUpdate. -- To view, visit https://gerrit.wikimedia.org/r/306324 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iefedef667234e64c0fd980cca5596488b4290cde Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core 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