Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CronJob/SonataIntegrationBundle] change error as json to text #255

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading