Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into retry-failed-mess…
Browse files Browse the repository at this point in the history
…age-from-admin
  • Loading branch information
DumitracheAdrian committed May 4, 2024
2 parents b8e3518 + a9fe129 commit fd2eb8a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/cron-job/CronJobProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Draw\Component\CronJob;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use Draw\Component\CronJob\Entity\CronJob;
use Draw\Component\CronJob\Entity\CronJobExecution;
Expand Down Expand Up @@ -40,6 +41,8 @@ public function process(CronJobExecution $execution): void
{
$manager = $this->managerRegistry->getManagerForClass(CronJobExecution::class);

\assert($manager instanceof EntityManagerInterface);

if (!$execution->isExecutable(new \DateTimeImmutable())) {
$execution->skip();
$manager->flush();
Expand All @@ -59,6 +62,10 @@ public function process(CronJobExecution $execution): void
$execution->start();
$manager->flush();

// This allows long process cron to release connection
// Also allow issue with server "gone away" to be resolved
$manager->getConnection()->close();

$process = $this->processFactory->createFromShellCommandLine(
$this->parameterBag->resolveValue(
$event->getCommand()
Expand Down
23 changes: 23 additions & 0 deletions packages/cron-job/Tests/CronJobProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Draw\Component\CronJob\Tests;

use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use Draw\Component\CronJob\CronJobProcessor;
Expand Down Expand Up @@ -130,6 +131,17 @@ public function testProcess(
->expects(static::exactly(2))
->method('flush');

$this->entityManager
->expects(static::once())
->method('getConnection')
->willReturn(
$connection = $this->createMock(Connection::class)
);

$connection
->expects(static::once())
->method('close');

$this->processFactory
->expects(static::once())
->method('createFromShellCommandLine')
Expand Down Expand Up @@ -197,6 +209,17 @@ public function testProcessWithError(): void
->expects(static::exactly(2))
->method('flush');

$this->entityManager
->expects(static::once())
->method('getConnection')
->willReturn(
$connection = $this->createMock(Connection::class)
);

$connection
->expects(static::once())
->method('close');

$process = $this->createMock(Process::class);
$process
->expects(static::any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@
{% for field in field_description.options.fields %}
{% if field.type != 'grid' %}
{% set colCount = colCount +1 %}
<th>{{ field.label }}</th>
<th>
{% apply spaceless %}
{% if field.label is not same as(false) %}
{% if field.translationDomain is same as(false) %}
{{ field.label }}
{% else %}
{{ field.label|trans({}, field.translationDomain) }}
{% endif %}
{% endif %}
{% endapply %}
</th>
{% endif %}
{% endfor %}
</tr>
Expand Down

0 comments on commit fd2eb8a

Please sign in to comment.