Skip to content

Commit

Permalink
[CronJob/SonataIntegrationBundle] change error as json to text
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoiriert committed Apr 25, 2024
1 parent 6aff2a9 commit 5fbab15
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
31 changes: 31 additions & 0 deletions app/migrations/Version20240425135611.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240425135611 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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');
}
}
7 changes: 6 additions & 1 deletion packages/cron-job/CronJobProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
);
}

Expand Down
10 changes: 5 additions & 5 deletions packages/cron-job/Entity/CronJobExecution.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
filterOptions: [
'show_filter' => true,
]
)
->add(
'error',
filterOptions: [
'show_filter' => true,
]
);

}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5fbab15

Please sign in to comment.