Enable setStatus to handle multiple WorkflowRuns at the same time

[MAILPOET-4731]
This commit is contained in:
David Remer
2022-10-24 13:02:31 +03:00
committed by Jan Jakeš
parent d60e399a3b
commit 7aa1a5f4ba
2 changed files with 9 additions and 5 deletions

View File

@@ -100,7 +100,7 @@ class StepHandler {
$this->handleStep($args);
} catch (Throwable $e) {
$status = $e instanceof InvalidStateException && $e->getErrorCode() === 'mailpoet_automation_workflow_not_active' ? WorkflowRun::STATUS_CANCELLED : WorkflowRun::STATUS_FAILED;
$this->workflowRunStorage->updateStatus((int)$args['workflow_run_id'], $status);
$this->workflowRunStorage->updateStatus($status, (int)$args['workflow_run_id']);
if (!$e instanceof Exception) {
throw new Exception($e->getMessage(), intval($e->getCode()), $e);
}
@@ -131,7 +131,7 @@ class StepHandler {
// complete workflow run
if (!$stepId) {
$this->workflowRunStorage->updateStatus($workflowRunId, WorkflowRun::STATUS_COMPLETE);
$this->workflowRunStorage->updateStatus(WorkflowRun::STATUS_COMPLETE, $workflowRunId);
return;
}
@@ -183,7 +183,7 @@ class StepHandler {
// no need to schedule a new step if the next step is null, complete the run
if (!$nextStep) {
$this->workflowRunStorage->updateStatus($workflowRunId, WorkflowRun::STATUS_COMPLETE);
$this->workflowRunStorage->updateStatus(WorkflowRun::STATUS_COMPLETE, $workflowRunId);
return;
}