cronos-bundle
cronos-bundle copied to clipboard
Symfony 5.3 LazyCommands are not parsed
The @Cron annotations are not parsed on LazyCommands.
Cf. https://symfony.com/blog/new-in-symfony-5-3-lazy-command-description
The fix above is working, but it is certainly not be the best way to fix this issue...
In https://github.com/mybuilder/cronos-bundle/blob/3.1.2/Command/CommandBase.php#L61, we use the Symfony application to fetch all commands : $commands = $this->getApplication()->all()
.
Since it may now return LazyCommand
instead of our commands, shouldn't cronos-bundle discover itself the Commands class ?
my workaround:
Exporter/AnnotationCronExporter.php
...
use Symfony\Component\Console\Command\LazyCommand;
...
public function export(array $commands, array $options): CronFormatter
{
$cron = $this->createCronConfiguration();
foreach ($commands as $command) {
if ($command instanceof LazyCommand) {
$command = $command->getCommand();
}
if ($command instanceof Command) {
$cron = $this->parseAnnotations($cron, $command, $options);
}
}
return $cron;
}
...