cron-bundle icon indicating copy to clipboard operation
cron-bundle copied to clipboard

Scan can't find new cron

Open Filoz opened this issue 2 years ago • 5 comments

Hi, I had a problem in Symfony 5.3 with the shapecode:cron:scan command because it couldn't find any CronJob.

I got deeper and I found that the problem was here: https://github.com/shapecode/cron-bundle/blob/master/src/EventListener/AnnotationJobLoaderListener.php#L40

Because of that https://symfony.com/blog/new-in-symfony-5-3-lazy-command-description

In my command I had a description like
class MyCommand extends Command { protected static $defaultDescription = '...';

and that was the problem!

With the description, the $this->application->all() return Symfony\Component\Console\Command\LazyCommand , instead of MyCommand class. Than the LazyCommand class is used as argument for the reflection in the next line $reflClass = new ReflectionClass($command);

Removing the description from MyCommand worked fine.

I hope that this little explanation could help someone when updating symfony

best regards

Filoz avatar Jul 29 '21 11:07 Filoz