diff --git a/app/migrations/Version20240425135611.php b/app/migrations/Version20240425135611.php new file mode 100644 index 00000000..210e968c --- /dev/null +++ b/app/migrations/Version20240425135611.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE cron_job__cron_job_execution CHANGE error error LONGTEXT DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE cron_job__cron_job_execution CHANGE error error JSON DEFAULT NULL'); + } +} diff --git a/packages/cron-job/CronJobProcessor.php b/packages/cron-job/CronJobProcessor.php index 9dbccfa3..213bed82 100644 --- a/packages/cron-job/CronJobProcessor.php +++ b/packages/cron-job/CronJobProcessor.php @@ -73,7 +73,12 @@ public function process(CronJobExecution $execution): void } catch (\Throwable $error) { $execution->fail( $process->getExitCode(), - (array) $error + sprintf( + "Error: %s\nOutput: %s\nError Output: %s\n", + $error->getMessage(), + $process->getOutput(), + $process->getErrorOutput() + ) ); } diff --git a/packages/cron-job/Entity/CronJobExecution.php b/packages/cron-job/Entity/CronJobExecution.php index f179173e..69850c47 100644 --- a/packages/cron-job/Entity/CronJobExecution.php +++ b/packages/cron-job/Entity/CronJobExecution.php @@ -57,8 +57,8 @@ class CronJobExecution implements \Stringable #[ORM\Column(name: 'exit_code', type: 'integer', nullable: true)] private ?int $exitCode = null; - #[ORM\Column(name: 'error', type: 'json', nullable: true)] - private ?array $error = null; + #[ORM\Column(name: 'error', type: 'text', nullable: true)] + private ?string $error = null; #[ ORM\ManyToOne( @@ -159,12 +159,12 @@ private function setExitCode(?int $exitCode): self return $this; } - public function getError(): ?array + public function getError(): ?string { return $this->error; } - private function setError(?array $error): self + private function setError(?string $error): self { $this->error = $error; @@ -216,7 +216,7 @@ public function end(): static return $this; } - public function fail(?int $exitCode, ?array $error): void + public function fail(?int $exitCode, string $error): void { $this ->end() diff --git a/packages/sonata-integration-bundle/CronJob/Admin/CronJobExecutionAdmin.php b/packages/sonata-integration-bundle/CronJob/Admin/CronJobExecutionAdmin.php index 002d0c8e..9796de52 100644 --- a/packages/sonata-integration-bundle/CronJob/Admin/CronJobExecutionAdmin.php +++ b/packages/sonata-integration-bundle/CronJob/Admin/CronJobExecutionAdmin.php @@ -56,6 +56,12 @@ protected function configureDatagridFilters(DatagridMapper $filter): void filterOptions: [ 'show_filter' => true, ] + ) + ->add( + 'error', + filterOptions: [ + 'show_filter' => true, + ] ); } @@ -102,7 +108,7 @@ protected function configureShowFields(ShowMapper $show): void ->add('executionEndedAt') ->add('executionDelay') ->add('exitCode') - ->add('error', 'json'); + ->add('error'); } protected function configureRoutes(RouteCollectionInterface $collection): void