diff --git a/mailpoet/lib/Automation/Engine/Control/TriggerHandler.php b/mailpoet/lib/Automation/Engine/Control/TriggerHandler.php index b4bac7958c..da812c81c9 100644 --- a/mailpoet/lib/Automation/Engine/Control/TriggerHandler.php +++ b/mailpoet/lib/Automation/Engine/Control/TriggerHandler.php @@ -64,19 +64,19 @@ class TriggerHandler { return; } + // ensure subjects are registered and loadable $subjects = $this->subjectTransformerHandler->getAllSubjects($subjects); + $subjectEntries = $this->subjectLoader->getSubjectsEntries($subjects); + foreach ($subjectEntries as $entry) { + $entry->getPayload(); + } + foreach ($automations as $automation) { $step = $automation->getTrigger($trigger->getKey()); if (!$step) { throw Exceptions::automationTriggerNotFound($automation->getId(), $trigger->getKey()); } - // ensure subjects are registered and loadable - $subjectEntries = $this->subjectLoader->getSubjectsEntries($subjects); - foreach ($subjectEntries as $entry) { - $entry->getPayload(); - } - $automationRun = new AutomationRun($automation->getId(), $automation->getVersionId(), $trigger->getKey(), $subjects); $stepRunArgs = new StepRunArgs($automation, $automationRun, $step, $subjectEntries); $createAutomationRun = $trigger->isTriggeredBy($stepRunArgs);