Skip to content

Commit

Permalink
Make sure we never lower the job next run (when rate limit is reached)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoLouwerse committed Dec 19, 2024
1 parent 7bbb47d commit 5eaa439
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/Cron/ActionTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,13 @@ public function run($argument)
if ($forceRun === false) {
$nextRun = new DateTime('now + ' . $job->getInterval() . ' seconds');
if (isset($result['nextRun']) === true) {
$nextRun = DateTime::createFromFormat('U', $result['nextRun'], $nextRun->getTimezone());
$nextRunRateLimit = DateTime::createFromFormat('U', $result['nextRun'], $nextRun->getTimezone());
// Check if the current seconds part is not zero, and if so, round up to the next minute
if ($nextRun->format('s') !== '00') {
$nextRun->modify('next minute');
if ($nextRunRateLimit->format('s') !== '00') {
$nextRunRateLimit->modify('next minute');
}
if ($nextRunRateLimit > $nextRun) {
$nextRun = $nextRunRateLimit;
}
}
$nextRun->setTime(hour: $nextRun->format('H'), minute: $nextRun->format('i'));
Expand Down

0 comments on commit 5eaa439

Please sign in to comment.