Skip to content

Commit 61fc1f3

Browse files
committed
merged pull requests j-guyon#181 j-guyon#183 j-guyon#187
1 parent f1e50c8 commit 61fc1f3

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
vendor/
22
composer.lock
33
build/
4-
.coveralls.yml
54
.php_cs.cache
65
.phpcs-cache
76
.phpunit.result.cache

Command/ExecuteCommand.php

+14-3
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
118118

119119
$noneExecution = true;
120120
foreach ($commands as $command) {
121-
$this->em->refresh($this->em->find(ScheduledCommand::class, $command));
121+
122+
// PullRequest: fix command refresh #183
123+
$command = $this->em->find(ScheduledCommand::class, $command->getId());
124+
122125
if ($command->isDisabled() || $command->isLocked()) {
123126
continue;
124127
}
125-
128+
$scheduledCommand = $this->em->find(ScheduledCommand::class, $scheduledCommand);
126129
/** @var ScheduledCommand $command */
127130
$cron = CronExpression::factory($command->getCronExpression());
128131
$nextRunDate = $cron->getNextRunDate($command->getLastExecution());
@@ -183,7 +186,10 @@ private function executeCommand(ScheduledCommand $scheduledCommand, OutputInterf
183186
$this->em->persist($scheduledCommand);
184187
$this->em->flush();
185188
$this->em->getConnection()->commit();
186-
} catch (\Exception $e) {
189+
// PullRequest: Clear ORM after run scheduled command #187
190+
$this->em->clear();
191+
} catch (\Throwable $e) {
192+
187193
$this->em->getConnection()->rollBack();
188194
$output->writeln(
189195
sprintf(
@@ -249,6 +255,11 @@ private function executeCommand(ScheduledCommand $scheduledCommand, OutputInterf
249255
$this->em = $this->em->create($this->em->getConnection(), $this->em->getConfiguration());
250256
}
251257

258+
// Reactivate the command in DB
259+
260+
// PullRequest: Fix repeated jobs #181
261+
$scheduledCommand = $this->em->find(ScheduledCommand::class, $scheduledCommand);
262+
252263
$scheduledCommand->setLastReturnCode($result);
253264
$scheduledCommand->setLocked(false);
254265
$scheduledCommand->setExecuteImmediately(false);

Resources/views/Detail/index.html.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
{# Form's actions #}
3232
<div class="row">
33-
<a href="{{ path('jmose_command_scheduler_list') }}" class="btn btn-default btn-lg" role="button">Cancel</a>
33+
<a href="{{ path('jmose_command_scheduler_list') }}" class="btn btn-default btn-lg" role="button">{{ 'action.cancel'|trans }}</a>
3434
{{ form_widget( scheduledCommandForm.save, {'attr': {'class': 'btn btn-success btn-lg pull-right'} } ) }}
3535
</div>
3636
{{ form_end( scheduledCommandForm ) }}

0 commit comments

Comments
 (0)