Skip to content

Commit

Permalink
Merge pull request #32116 from nextcloud/backport/32109/stable24
Browse files Browse the repository at this point in the history
[stable24] Get not only time-sensitive next job from list but any when not in cron-mode
  • Loading branch information
PVince81 authored Apr 25, 2022
2 parents d1e244b + edfba7f commit 8f34bc8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
break;
}

$logger->debug('CLI cron call has selected job with ID ' . strval($job->getId()), ['app' => 'cron']);
$job->execute($jobList, $logger);
// clean up after unclean jobs
\OC_Util::tearDownFS();
Expand All @@ -169,6 +170,7 @@
$jobList = \OC::$server->getJobList();
$job = $jobList->getNext();
if ($job != null) {
$logger->debug('WebCron call has selected job with ID ' . strval($job->getId()), ['app' => 'cron']);
$job->execute($jobList, $logger);
$jobList->setLastJob($job);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/private/BackgroundJob/JobList.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function getAll() {
* @param bool $onlyTimeSensitive
* @return IJob|null
*/
public function getNext(bool $onlyTimeSensitive = true): ?IJob {
public function getNext(bool $onlyTimeSensitive = false): ?IJob {
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from('jobs')
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/BackgroundJob/DummyJobList.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getAll() {
* @param bool $onlyTimeSensitive
* @return IJob|null
*/
public function getNext(bool $onlyTimeSensitive = true): ?IJob {
public function getNext(bool $onlyTimeSensitive = false): ?IJob {
if (count($this->jobs) > 0) {
if ($this->last < (count($this->jobs) - 1)) {
$i = $this->last + 1;
Expand Down

0 comments on commit 8f34bc8

Please sign in to comment.