Remove redundant step args from log
[MAILPOET-4463]
This commit is contained in:
committed by
Jan Jakeš
parent
d0f8d0f2bb
commit
c828b7245d
@@ -120,7 +120,7 @@ class StepHandler {
|
|||||||
|
|
||||||
$stepType = $step->getType();
|
$stepType = $step->getType();
|
||||||
if (isset($this->stepRunners[$stepType])) {
|
if (isset($this->stepRunners[$stepType])) {
|
||||||
$log = new WorkflowRunLog($workflowRun->getId(), $step->getId(), $args);
|
$log = new WorkflowRunLog($workflowRun->getId(), $step->getId());
|
||||||
try {
|
try {
|
||||||
$this->stepRunners[$stepType]->run($step, $workflow, $workflowRun);
|
$this->stepRunners[$stepType]->run($step, $workflow, $workflowRun);
|
||||||
$log->markCompletedSuccessfully();
|
$log->markCompletedSuccessfully();
|
||||||
|
@@ -39,18 +39,13 @@ class WorkflowRunLog {
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
private $stepId;
|
private $stepId;
|
||||||
|
|
||||||
/** @var array */
|
|
||||||
private $args;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
int $workflowRunId,
|
int $workflowRunId,
|
||||||
string $stepId,
|
string $stepId,
|
||||||
array $args,
|
|
||||||
int $id = null
|
int $id = null
|
||||||
) {
|
) {
|
||||||
$this->workflowRunId = $workflowRunId;
|
$this->workflowRunId = $workflowRunId;
|
||||||
$this->stepId = $stepId;
|
$this->stepId = $stepId;
|
||||||
$this->args = $args;
|
|
||||||
$this->status = self::STATUS_RUNNING;
|
$this->status = self::STATUS_RUNNING;
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
@@ -79,10 +74,6 @@ class WorkflowRunLog {
|
|||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArgs(): array {
|
|
||||||
return $this->args;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getError(): array {
|
public function getError(): array {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
@@ -126,7 +117,6 @@ class WorkflowRunLog {
|
|||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'started_at' => $this->startedAt->format(DateTimeImmutable::W3C),
|
'started_at' => $this->startedAt->format(DateTimeImmutable::W3C),
|
||||||
'completed_at' => $this->completedAt ? $this->completedAt->format(DateTimeImmutable::W3C) : null,
|
'completed_at' => $this->completedAt ? $this->completedAt->format(DateTimeImmutable::W3C) : null,
|
||||||
'args' => Json::encode($this->args),
|
|
||||||
'error' => Json::encode($this->error),
|
'error' => Json::encode($this->error),
|
||||||
'data' => Json::encode($this->data),
|
'data' => Json::encode($this->data),
|
||||||
];
|
];
|
||||||
@@ -154,12 +144,11 @@ class WorkflowRunLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function fromArray(array $data): self {
|
public static function fromArray(array $data): self {
|
||||||
$workflowRunLog = new WorkflowRunLog((int)$data['workflow_run_id'], $data['step_id'], []);
|
$workflowRunLog = new WorkflowRunLog((int)$data['workflow_run_id'], $data['step_id']);
|
||||||
$workflowRunLog->id = (int)$data['id'];
|
$workflowRunLog->id = (int)$data['id'];
|
||||||
$workflowRunLog->status = $data['status'];
|
$workflowRunLog->status = $data['status'];
|
||||||
$workflowRunLog->error = Json::decode($data['error']);
|
$workflowRunLog->error = Json::decode($data['error']);
|
||||||
$workflowRunLog->data = Json::decode($data['data']);
|
$workflowRunLog->data = Json::decode($data['data']);
|
||||||
$workflowRunLog->args = Json::decode($data['args']);
|
|
||||||
$workflowRunLog->startedAt = new DateTimeImmutable($data['started_at']);
|
$workflowRunLog->startedAt = new DateTimeImmutable($data['started_at']);
|
||||||
|
|
||||||
if ($data['completed_at']) {
|
if ($data['completed_at']) {
|
||||||
|
@@ -70,7 +70,6 @@ class Migrator {
|
|||||||
status varchar(255) NOT NULL,
|
status varchar(255) NOT NULL,
|
||||||
started_at timestamp NOT NULL,
|
started_at timestamp NOT NULL,
|
||||||
completed_at timestamp NULL DEFAULT NULL,
|
completed_at timestamp NULL DEFAULT NULL,
|
||||||
args longtext,
|
|
||||||
error longtext,
|
error longtext,
|
||||||
data longtext,
|
data longtext,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
|
@@ -50,7 +50,7 @@ class WorkflowRunLogTest extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItAllowsSettingData(): void {
|
public function testItAllowsSettingData(): void {
|
||||||
$log = new WorkflowRunLog(1, 'step-id', []);
|
$log = new WorkflowRunLog(1, 'step-id');
|
||||||
$this->assertSame([], $log->getData());
|
$this->assertSame([], $log->getData());
|
||||||
$log->setData('key', 'value');
|
$log->setData('key', 'value');
|
||||||
$data = $log->getData();
|
$data = $log->getData();
|
||||||
@@ -59,7 +59,7 @@ class WorkflowRunLogTest extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItDoesNotAllowSettingDataThatCannotBeSaved(): void {
|
public function testItDoesNotAllowSettingDataThatCannotBeSaved(): void {
|
||||||
$log = new WorkflowRunLog(1, 'step-id', []);
|
$log = new WorkflowRunLog(1, 'step-id');
|
||||||
$badData = [
|
$badData = [
|
||||||
function() { echo 'closures cannot be serialized'; }
|
function() { echo 'closures cannot be serialized'; }
|
||||||
];
|
];
|
||||||
@@ -157,12 +157,6 @@ class WorkflowRunLogTest extends \MailPoetTest {
|
|||||||
expect(count($error['trace']))->greaterThan(0);
|
expect(count($error['trace']))->greaterThan(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItLogsStepArgs(): void {
|
|
||||||
$log = $this->getLogsForAction()[0];
|
|
||||||
expect($log->getArgs())->count(2);
|
|
||||||
expect(array_keys($log->getArgs()))->equals(['workflow_run_id', 'step_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function _after() {
|
public function _after() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$sql = 'truncate ' . $wpdb->prefix . 'mailpoet_workflow_run_logs';
|
$sql = 'truncate ' . $wpdb->prefix . 'mailpoet_workflow_run_logs';
|
||||||
|
@@ -15,7 +15,7 @@ class WorkflowRunLogStorageTest extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItSavesAndRetrievesAsExpected() {
|
public function testItSavesAndRetrievesAsExpected() {
|
||||||
$log = new WorkflowRunLog(1, 'step-id', []);
|
$log = new WorkflowRunLog(1, 'step-id');
|
||||||
$log->setData('key', 'value');
|
$log->setData('key', 'value');
|
||||||
$log->setData('key2', ['arrayData']);
|
$log->setData('key2', ['arrayData']);
|
||||||
$preSave = $log->toArray();
|
$preSave = $log->toArray();
|
||||||
@@ -26,7 +26,7 @@ class WorkflowRunLogStorageTest extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItCanStoreAnError() {
|
public function testItCanStoreAnError() {
|
||||||
$log = new WorkflowRunLog(1, 'step-id', []);
|
$log = new WorkflowRunLog(1, 'step-id');
|
||||||
$log->setError(new \Exception('test'));
|
$log->setError(new \Exception('test'));
|
||||||
$id = $this->storage->createWorkflowRunLog($log);
|
$id = $this->storage->createWorkflowRunLog($log);
|
||||||
$log = $this->storage->getWorkflowRunLog($id);
|
$log = $this->storage->getWorkflowRunLog($id);
|
||||||
|
Reference in New Issue
Block a user