-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented dynamic maxIterationCount for getRunDate() #89
Conversation
@@ -36,7 +36,10 @@ public function isSatisfiedBy(\DateTime $date, $value) | |||
$tdate = clone $date; | |||
$tdate->setDate($currentYear, $currentMonth, $lastDayOfMonth); | |||
while ($tdate->format('w') != $weekday) { | |||
$tdate->setDate($currentYear, $currentMonth, --$lastDayOfMonth); | |||
$tdateClone = new \DateTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason the day of $tdate
stays the same when using setDate();
. This leads to an infinite loop since $tdate->format('w')
is unchanged. This is not the most beautiful workaround, but it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change belongs in this PR. Can you remove it please?
5fbc9a5
to
63328b5
Compare
I have reverted the changes. |
@@ -275,6 +275,21 @@ public function testProvidesMultipleRunDates() | |||
new DateTime('2008-11-09 00:04:00'), | |||
new DateTime('2008-11-09 00:06:00') | |||
), $cron->getMultipleRunDates(4, '2008-11-09 00:00:00', false, true)); | |||
|
|||
// Fails with the default 1000 iteration limit | |||
$cron = CronExpression::factory('0 0 12 1 * */2'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you break this out into it's own test?
@dragonmantank I have moved the code to a separate test. |
Implemented dynamic maxIterationCount for getRunDate()
I have implemented a
maxIterationCount
property that is used as the limit to bail on an impossible date ingetRunDate()
.When generating run dates that lie further in the future, the hard coded 1000 iterations aren't always enough (see Issue #66).
To work around this, you can now set the
maxIterationCount
via the setter methodsetMaxIterationCount
.