The SendEmailAction step needs to log arbitrary data to allow retry-runs, through a StepRunLogger. We previously instanciated a logger from the action, but this data will be overwritten by the handler right after the action is run. This is because the handler holds a reference to a logger already, and will overwrite any data the action tries to write. To work around this issue, the step handler now passes its logger instance to the step's controller, allowing safe access from SendEmailAction. [MAILPOET-6176]
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php declare(strict_types = 1);
|
|
|
|
namespace MailPoet\Automation\Engine\Control;
|
|
|
|
use MailPoet\Automation\Engine\Control\StepRunLogger;
|
|
use MailPoet\Automation\Engine\Data\StepRunArgs;
|
|
|
|
class StepRunController {
|
|
/** @var StepScheduler */
|
|
private $stepScheduler;
|
|
|
|
/** @var StepRunArgs */
|
|
private $stepRunArgs;
|
|
|
|
/** @var StepRunLogger */
|
|
private $stepRunLogger;
|
|
|
|
public function __construct(
|
|
StepScheduler $stepScheduler,
|
|
StepRunArgs $stepRunArgs,
|
|
StepRunLogger $stepRunLogger
|
|
) {
|
|
$this->stepScheduler = $stepScheduler;
|
|
$this->stepRunArgs = $stepRunArgs;
|
|
$this->stepRunLogger = $stepRunLogger;
|
|
}
|
|
|
|
public function scheduleProgress(int $timestamp = null): int {
|
|
return $this->stepScheduler->scheduleProgress($this->stepRunArgs, $timestamp);
|
|
}
|
|
|
|
public function scheduleNextStep(int $timestamp = null): int {
|
|
return $this->stepScheduler->scheduleNextStep($this->stepRunArgs, $timestamp);
|
|
}
|
|
|
|
public function scheduleNextStepByIndex(int $nextStepIndex, int $timestamp = null): int {
|
|
return $this->stepScheduler->scheduleNextStepByIndex($this->stepRunArgs, $nextStepIndex, $timestamp);
|
|
}
|
|
|
|
public function hasScheduledNextStep(): bool {
|
|
return $this->stepScheduler->hasScheduledNextStep($this->stepRunArgs);
|
|
}
|
|
|
|
public function getRunLog(): StepRunLogger {
|
|
return $this->stepRunLogger;
|
|
}
|
|
}
|