Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/301069
Change subject: Simplify and cleanup SubmissionHandler transaction
......................................................................
Simplify and cleanup SubmissionHandler transaction
Wrap everything in an atomic section to avoid having to delete
pages on failure. This avoids dangling pages if the DB connection
is lost (as the page delete would fail). It also avoids notices
about breaking implicit transactions.
Note that the page creation/modification methods in core also
use nestable atomic sections rather than begin/commit, which
they have not used for some time.
Bug: T141172
Change-Id: I01098002565afd6fd454ea10ac049c73b7507ab8
---
M includes/SubmissionHandler.php
1 file changed, 16 insertions(+), 32 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/69/301069/1
diff --git a/includes/SubmissionHandler.php b/includes/SubmissionHandler.php
index 42c8c92..a98f9a9 100644
--- a/includes/SubmissionHandler.php
+++ b/includes/SubmissionHandler.php
@@ -132,54 +132,38 @@
$cache = $this->bufferedCache;
$dbw = $this->dbFactory->getDB( DB_MASTER );
- /**
- * Ideally, I'd create the page in Workflow::toStorageRow, but
- * WikiPage::doEditContent uses transactions & our DB wrapper
- * doesn't allow nested transactions, so that part has moved.
- *
- * Don't safeAllowCreation() here: a board has to be explicitly
created,
- * or allowed via the namespace content model, in which case
- * safeAllowCreation() won't be needed.
- *
- * @var OccupationController $occupationController
- */
+ /** @var OccupationController $occupationController */
$occupationController = Container::get( 'occupation_controller'
);
$title = $workflow->getOwnerTitle();
- $occupationController->ensureFlowRevision( new \Article( $title
), $workflow );
- $isNew = $workflow->isNew();
-
try {
- $dbw->begin( __METHOD__ );
+ $dbw->startAtomic( __METHOD__ );
$cache->begin();
+ // Create the occupation page/revision if needed
+ $occupationController->ensureFlowRevision( new
\Article( $title ), $workflow );
+ // Create/modify each Flow block as requested
$results = array();
foreach ( $blocks as $block ) {
$results[$block->getName()] = $block->commit();
}
- $dbw->commit( __METHOD__ );
-
- // Now commit to cache. If this fails, cache keys
should have been
- // invalidated, but still log the failure.
- if ( !$cache->commit() ) {
- wfDebugLog( 'Flow', __METHOD__ . ': Committed
to database but failed applying to cache' );
- }
+ $dbw->endAtomic( __METHOD__ );
+ $dbw->onTransactionIdle( function () use ( $cache ) {
+ // Now commit to cache. If this fails, cache
keys should have been
+ // invalidated, but still log the failure.
+ if ( !$cache->commit() ) {
+ wfDebugLog( 'Flow', __METHOD__ .
+ ': Committed to database but
failed applying to cache' );
+ }
+ } );
} catch ( \Exception $e ) {
- while( !$this->deferredQueue->isEmpty() ) {
+ while ( !$this->deferredQueue->isEmpty() ) {
$this->deferredQueue->dequeue();
}
-
- if ( $isNew ) {
- $article = new \Article( $title );
- $page = $article->getPage();
- $reason = '/* Failed to create Flow board */';
- $page->doDeleteArticleReal( $reason, false, 0,
true, $errors, $occupationController->getTalkpageManager() );
- }
-
$dbw->rollback( __METHOD__ );
$cache->rollback();
throw $e;
}
- while( !$this->deferredQueue->isEmpty() ) {
+ while ( !$this->deferredQueue->isEmpty() ) {
DeferredUpdates::addCallableUpdate(
$this->deferredQueue->dequeue() );
}
--
To view, visit https://gerrit.wikimedia.org/r/301069
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I01098002565afd6fd454ea10ac049c73b7507ab8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits