Fix bug where the type of $step was Data\Step instead of Integration\Step
[MAILPOET-4530]
This commit is contained in:
@@ -16,6 +16,7 @@ use MailPoet\Automation\Engine\Hooks;
|
|||||||
use MailPoet\Automation\Engine\Integration\Action;
|
use MailPoet\Automation\Engine\Integration\Action;
|
||||||
use MailPoet\Automation\Engine\Integration\Payload;
|
use MailPoet\Automation\Engine\Integration\Payload;
|
||||||
use MailPoet\Automation\Engine\Integration\Subject;
|
use MailPoet\Automation\Engine\Integration\Subject;
|
||||||
|
use MailPoet\Automation\Engine\Registry;
|
||||||
use MailPoet\Automation\Engine\Storage\WorkflowRunLogStorage;
|
use MailPoet\Automation\Engine\Storage\WorkflowRunLogStorage;
|
||||||
use MailPoet\Automation\Engine\Storage\WorkflowRunStorage;
|
use MailPoet\Automation\Engine\Storage\WorkflowRunStorage;
|
||||||
use MailPoet\Automation\Engine\Storage\WorkflowStorage;
|
use MailPoet\Automation\Engine\Storage\WorkflowStorage;
|
||||||
@@ -50,6 +51,9 @@ class StepHandler {
|
|||||||
/** @var Hooks */
|
/** @var Hooks */
|
||||||
private $hooks;
|
private $hooks;
|
||||||
|
|
||||||
|
/** @var Registry */
|
||||||
|
private $registry;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ActionScheduler $actionScheduler,
|
ActionScheduler $actionScheduler,
|
||||||
ActionStepRunner $actionStepRunner,
|
ActionStepRunner $actionStepRunner,
|
||||||
@@ -58,7 +62,8 @@ class StepHandler {
|
|||||||
WordPress $wordPress,
|
WordPress $wordPress,
|
||||||
WorkflowRunStorage $workflowRunStorage,
|
WorkflowRunStorage $workflowRunStorage,
|
||||||
WorkflowRunLogStorage $workflowRunLogStorage,
|
WorkflowRunLogStorage $workflowRunLogStorage,
|
||||||
WorkflowStorage $workflowStorage
|
WorkflowStorage $workflowStorage,
|
||||||
|
Registry $registry
|
||||||
) {
|
) {
|
||||||
$this->actionScheduler = $actionScheduler;
|
$this->actionScheduler = $actionScheduler;
|
||||||
$this->actionStepRunner = $actionStepRunner;
|
$this->actionStepRunner = $actionStepRunner;
|
||||||
@@ -68,6 +73,7 @@ class StepHandler {
|
|||||||
$this->workflowRunStorage = $workflowRunStorage;
|
$this->workflowRunStorage = $workflowRunStorage;
|
||||||
$this->workflowRunLogStorage = $workflowRunLogStorage;
|
$this->workflowRunLogStorage = $workflowRunLogStorage;
|
||||||
$this->workflowStorage = $workflowStorage;
|
$this->workflowStorage = $workflowStorage;
|
||||||
|
$this->registry = $registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initialize(): void {
|
public function initialize(): void {
|
||||||
@@ -124,19 +130,19 @@ class StepHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$step = $workflow->getStep($stepId);
|
$stepData = $workflow->getStep($stepId);
|
||||||
if (!$step) {
|
if (!$stepData) {
|
||||||
throw Exceptions::workflowStepNotFound($stepId);
|
throw Exceptions::workflowStepNotFound($stepId);
|
||||||
}
|
}
|
||||||
|
$step = $this->registry->getStep($stepData->getKey());
|
||||||
$stepType = $step->getType();
|
$stepType = $stepData->getType();
|
||||||
if (isset($this->stepRunners[$stepType])) {
|
if (isset($this->stepRunners[$stepType])) {
|
||||||
$log = new WorkflowRunLog($workflowRun->getId(), $step->getId());
|
$log = new WorkflowRunLog($workflowRun->getId(), $stepData->getId());
|
||||||
try {
|
try {
|
||||||
$requiredSubjects = $step instanceof Action ? $step->getSubjectKeys() : [];
|
$requiredSubjects = $step instanceof Action ? $step->getSubjectKeys() : [];
|
||||||
$subjectEntries = $this->getSubjectEntries($workflowRun, $requiredSubjects);
|
$subjectEntries = $this->getSubjectEntries($workflowRun, $requiredSubjects);
|
||||||
$args = new StepRunArgs($workflow, $workflowRun, $step, $subjectEntries);
|
$args = new StepRunArgs($workflow, $workflowRun, $stepData, $subjectEntries);
|
||||||
$validationArgs = new StepValidationArgs($workflow, $step, array_map(function (SubjectEntry $entry) {
|
$validationArgs = new StepValidationArgs($workflow, $stepData, array_map(function (SubjectEntry $entry) {
|
||||||
return $entry->getSubject();
|
return $entry->getSubject();
|
||||||
}, $subjectEntries));
|
}, $subjectEntries));
|
||||||
$this->stepRunners[$stepType]->run($args, $validationArgs);
|
$this->stepRunners[$stepType]->run($args, $validationArgs);
|
||||||
@@ -157,7 +163,7 @@ class StepHandler {
|
|||||||
throw new InvalidStateException();
|
throw new InvalidStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$nextStep = $step->getNextSteps()[0] ?? null;
|
$nextStep = $stepData->getNextSteps()[0] ?? null;
|
||||||
$nextStepArgs = [
|
$nextStepArgs = [
|
||||||
[
|
[
|
||||||
'workflow_run_id' => $workflowRunId,
|
'workflow_run_id' => $workflowRunId,
|
||||||
|
Reference in New Issue
Block a user