Skip to content

Commit

Permalink
Merge branch 'release/1.7.44'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jan 5, 2024
2 parents 171a5c0 + 3ea86e1 commit 78b8125
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 195 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
## 01/05/2024

1. [](#new)
* Added new `outdated` option to schedule command [#3771](https://github.com/getgrav/grav/pull/3771)
* Added PHP `8.3` to tests [#3782](https://github.com/getgrav/grav/pull/3782)
* Added debugger messages when Page routes conflict
* Added `ISO 8601` date format [#3721](https://github.com/getgrav/grav/pull/37210)
Expand Down
22 changes: 0 additions & 22 deletions system/src/Grav/Common/Scheduler/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,6 @@ public function isDue(DateTime $date = null)
return $this->executionTime->isDue($date);
}

/**
* Check if the Job should have run previously.
*
* @param DateTime|null $date
* @return bool
*/
public function isOverdue(?DateTime $date = null, ?DateTime $lastRun = null)
{
// If the time elapsed since the creation is inferior to the interval, it's not overdue
if ($this->creationTime > $this->executionTime->getPreviousRunDate($date)) {
return false;
}
// Else, if the job has never run, it's overdue
if (null === $lastRun) {
return true;
}
$date = $date ?? new DateTime('now');

// Else if the last run time is inferior to the previous scheduled time, it's overdue
return $lastRun < $this->executionTime->getPreviousRunDate($date);
}

/**
* Check if the Job is overlapping.
*
Expand Down
12 changes: 2 additions & 10 deletions system/src/Grav/Common/Scheduler/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function addCommand($command, $args = [], $id = null)
* @param DateTime|null $runTime Optional, run at specific moment
* @param bool $force force run even if not due
*/
public function run(DateTime $runTime = null, $force = false, $overdue = false)
public function run(DateTime $runTime = null, $force = false)
{
$this->loadSavedJobs();

Expand All @@ -199,17 +199,9 @@ public function run(DateTime $runTime = null, $force = false, $overdue = false)
$runTime = new DateTime('now');
}

if ($overdue) {
$lastRuns = [];
foreach ($this->getJobStates()->content() as $id => $state) {
$timestamp = $state['last-run'] ?? time();
$lastRuns[$id] = DateTime::createFromFormat('U',$timestamp);
}
}

// Star processing jobs
foreach ($alljobs as $job) {
if ($job->isDue($runTime) || $force || ($overdue && $job->isOverdue($runTime, $lastRuns[$job->getId()] ?? null))) {
if ($job->isDue($runTime) || $force) {
$job->run();
$this->jobs_run[] = $job;
}
Expand Down
82 changes: 0 additions & 82 deletions tests/unit/Grav/Common/Scheduler/JobTest.php

This file was deleted.

80 changes: 0 additions & 80 deletions tests/unit/Grav/Common/Scheduler/SchedulerTest.php

This file was deleted.

0 comments on commit 78b8125

Please sign in to comment.