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.89k stars 337 forks source link

0 0 0 * * seems to be valid! #120

Closed bentcoder closed 7 years ago

bentcoder commented 8 years ago

Hi,

Unfortunately code below passes! Date cannot be 0.

Regards

Code

$isValid = VendorCronExpression::isValidExpression('0 0 0 * *');
echo 'TYPE:'.gettype($isValid);
echo PHP_EOL;
echo 'VALUE:'.$isValid;

Result

TYPE:boolean
VALUE:1
bentcoder commented 8 years ago

I guess you have a problem with https://github.com/mtdowling/cron-expression/blob/30a65ae8bcda39e11e11b97c1c126284e3f8ea8a/src/Cron/DayOfMonthField.php#L101

dragonmantank commented 8 years ago

Yup, you are correct. DayOfMonth should be 1-31, not 0-31. I'll make sure this gets fixed by the next release.

dragonmantank commented 7 years ago

This is finally corrected in dda25ed935212b6dbef0c89116bcec01c9c262f3, and will be part of the next release. Turns out that regex let a lot of things through it should not have.