mtdowling / cron-expression

CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
http://mtdowling.com/blog/2012/06/03/cron-expressions-in-php/
MIT License
4.9k stars 335 forks source link

Yii2 yii2mod/yii2-scheduling - InvalidArgumentException: 5 is not a valid position #177

Closed DesRodman closed 4 years ago

DesRodman commented 4 years ago

Good day

After last updating of extensions (by "composer update"), i had a problem with scheduler

2019-12-28 08:29:01 [-][-][-][error][InvalidArgumentException] InvalidArgumentException: 5 is not a valid position in /home/rodman/Development/smpp-gateway/vendor/mtdowling/cron-expression/src/Cron/FieldFactory.php:46
Stack trace:
#0 /home/rodman/Development/smpp-gateway/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php(153): Cron\FieldFactory->getField(5)
#1 /home/rodman/Development/smpp-gateway/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php(136): Cron\CronExpression->setPart(5, '*')
#2 /home/rodman/Development/smpp-gateway/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php(115): Cron\CronExpression->setExpression('* * * * * *')
#3 /home/rodman/Development/smpp-gateway/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php(84): Cron\CronExpression->__construct('* * * * * *', Object(Cron\FieldFactory))
#4 /home/rodman/Development/smpp-gateway/vendor/yii2mod/yii2-scheduling/Event.php(197): Cron\CronExpression::factory('* * * * * *')
#5 /home/rodman/Development/smpp-gateway/vendor/yii2mod/yii2-scheduling/Event.php(182): yii2mod\scheduling\Event->expressionPasses()
#6 /home/rodman/Development/smpp-gateway/vendor/yii2mod/yii2-scheduling/Schedule.php(81): yii2mod\scheduling\Event->isDue(Object(yii\console\Application))
#7 [internal function]: yii2mod\scheduling\Schedule->yii2mod\scheduling\{closure}(Object(yii2mod\scheduling\Event))
#8 /home/rodman/Development/smpp-gateway/vendor/yii2mod/yii2-scheduling/Schedule.php(82): array_filter(Array, Object(Closure))
#9 /home/rodman/Development/smpp-gateway/vendor/yii2mod/yii2-scheduling/ScheduleController.php(61): yii2mod\scheduling\Schedule->dueEvents(Object(yii\console\Application))
#10 [internal function]: yii2mod\scheduling\ScheduleController->actionRun()
#11 /home/rodman/Development/smpp-gateway/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /home/rodman/Development/smpp-gateway/vendor/yiisoft/yii2/base/Controller.php(158): yii\base\InlineAction->runWithParams(Array)
#13 /home/rodman/Development/smpp-gateway/vendor/yiisoft/yii2/console/Controller.php(164): yii\base\Controller->runAction('run', Array)
#14 /home/rodman/Development/smpp-gateway/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('run', Array)
#15 /home/rodman/Development/smpp-gateway/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('schedule/run', Array)
#16 /home/rodman/Development/smpp-gateway/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('schedule/run', Array)
#17 /home/rodman/Development/smpp-gateway/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#18 /home/rodman/Development/smpp-gateway/yii(27): yii\base\Application->run()
#19 {main}

I made replace for elder version and it begun working... but last version has this problem

dragonmantank commented 4 years ago

It looks like the yii2mod/yii2-scheduling library never updated this library once it was moved a few years ago. I will put in a PR to have that updated.

The 1.2.2 release was improperly tagged off of master, which had a breaking change. Feel free to either lock at 1.2.1 or re-run composer update to have it grab 1.2.3.

DesRodman commented 4 years ago

I dont know why was import a new version of your script per yii2mod/yii2-scheduling, but result was so bad...

Now i checked - and its working... thanks a lot