Add check that next step was scheduled when multiple next steps are possible

[MAILPOET-5586]
This commit is contained in:
Jan Jakes
2023-09-14 15:03:12 +02:00
committed by Aschepikov
parent 72ce5fb569
commit 32e5d4f8ac
2 changed files with 15 additions and 1 deletions

View File

@@ -30,13 +30,19 @@ class StepScheduler {
}
public function scheduleNextStep(StepRunArgs $args, int $timestamp = null): int {
$nextSteps = $args->getStep()->getNextSteps();
$step = $args->getStep();
$nextSteps = $step->getNextSteps();
// complete the automation run if there are no more steps
if (count($nextSteps) === 0) {
$this->completeAutomationRun($args);
return 0;
}
if (count($nextSteps) > 1) {
throw Exceptions::nextStepNotScheduled($step->getId());
}
return $this->scheduleNextStepByIndex($args, 0, $timestamp);
}