In \Cron\CronExpression::getRunDate method, cron expressions with both day-of-month and day-of-week set are detected with special if (isset($parts[2]) && isset($parts[4])) check, and treated differently than other patterns. In this execution branch, the expression is treated as two separate expressions with wildcards instead of one of the dwo day parameters. The results are merged and sorted, and after that the corresponding $nth result is returned.
However, this method is used internally by both getNextRunDate and getPreviousRunDate methods of the class, and yet the sorting order is incorrectly the same in both cases, irrespective of the $invert parameter passed to the method.
This pull request fixes the bug and adds a test to prevent a future regression.
In
\Cron\CronExpression::getRunDate
method, cron expressions with both day-of-month and day-of-week set are detected with specialif (isset($parts[2]) && isset($parts[4]))
check, and treated differently than other patterns. In this execution branch, the expression is treated as two separate expressions with wildcards instead of one of the dwo day parameters. The results are merged and sorted, and after that the corresponding$nth
result is returned.However, this method is used internally by both
getNextRunDate
andgetPreviousRunDate
methods of the class, and yet the sorting order is incorrectly the same in both cases, irrespective of the$invert
parameter passed to the method.This pull request fixes the bug and adds a test to prevent a future regression.