jenkins-bot has submitted this change and it was merged.
Change subject: Fix error-handling for handleSubmit
......................................................................
Fix error-handling for handleSubmit
* EnableFlow - Don't commit if there are errors
* If something tries to commit when there are errors, throw an
exception.
I noticed this was causing inconsistent state when I was working
on T131957 (it failed since the topic title was missing, but
caused inconsistent state).
Change-Id: I58bfdc535b03a1f180a5475713075c5c2a84d99d
---
M includes/Specials/SpecialEnableFlow.php
M includes/SubmissionHandler.php
2 files changed, 19 insertions(+), 2 deletions(-)
Approvals:
Sbisson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Specials/SpecialEnableFlow.php
b/includes/Specials/SpecialEnableFlow.php
index 514b6f1..6da6642 100644
--- a/includes/Specials/SpecialEnableFlow.php
+++ b/includes/Specials/SpecialEnableFlow.php
@@ -153,7 +153,9 @@
}
}
- $loader->commit( $blocksToCommit );
+ if ( $status->isOK() ) {
+ $loader->commit( $blocksToCommit );
+ }
}
$this->page = $data['page'];
diff --git a/includes/SubmissionHandler.php b/includes/SubmissionHandler.php
index a98f9a9..e277d6f 100644
--- a/includes/SubmissionHandler.php
+++ b/includes/SubmissionHandler.php
@@ -7,6 +7,7 @@
use Flow\Block\Block;
use Flow\Data\BufferedCache;
use Flow\Data\ManagerGroup;
+use Flow\Exception\FailCommitException;
use Flow\Exception\InvalidDataException;
use Flow\Exception\InvalidActionException;
use Flow\Model\Workflow;
@@ -125,7 +126,8 @@
* @param Workflow $workflow
* @param AbstractBlock[] $blocks
* @return array Map from committed block name to an array of metadata
returned
- * about inserted objects.
+ * about inserted objects. This must be non-empty. An empty block
array
+ * indicates there were errors, in which case this method should not
be called.
* @throws \Exception
*/
public function commit( Workflow $workflow, array $blocks ) {
@@ -135,6 +137,19 @@
/** @var OccupationController $occupationController */
$occupationController = Container::get( 'occupation_controller'
);
$title = $workflow->getOwnerTitle();
+
+ if ( count( $blocks ) === 0 ) {
+ // This is a logic error in the code, but we need to
preserve
+ // consistent state.
+ throw new FailCommitException(
+ __METHOD__ . ' was called with $blocks set to
an empty ' .
+ 'array or a falsy value. This indicates the
blocks are ' .
+ 'not able to commit, so ' . __METHOD__ . '
should not be ' .
+ 'called.',
+ 'fail-commit'
+ );
+ }
+
try {
$dbw->startAtomic( __METHOD__ );
$cache->begin();
--
To view, visit https://gerrit.wikimedia.org/r/309636
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I58bfdc535b03a1f180a5475713075c5c2a84d99d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits