summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-08-19 14:16:05 +0200
committerRobin Appelman <icewind@owncloud.com>2015-08-19 14:16:05 +0200
commitbeaef820cf67d96652cd0774b151061d7ecd963a (patch)
tree21a069f82784c53d89930029d5bbe568695e8420 /lib
parent74237a9c44192fb98944ea7f3c14fa6f22c0814b (diff)
downloadnextcloud-server-beaef820cf67d96652cd0774b151061d7ecd963a.tar.gz
nextcloud-server-beaef820cf67d96652cd0774b151061d7ecd963a.zip
handle non existing job classes in $jobList->getNext
Diffstat (limited to 'lib')
-rw-r--r--lib/private/backgroundjob/joblist.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php
index e8915b47f24..f297bccbc7d 100644
--- a/lib/private/backgroundjob/joblist.php
+++ b/lib/private/backgroundjob/joblist.php
@@ -87,6 +87,11 @@ class JobList implements IJobList {
}
}
+ protected function removeById($id) {
+ $query = $this->conn->prepare('DELETE FROM `*PREFIX*jobs` WHERE `id` = ?');
+ $query->execute([$id]);
+ }
+
/**
* check if a job is in the list
*
@@ -134,17 +139,25 @@ class JobList implements IJobList {
$query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` > ? ORDER BY `id` ASC', 1);
$query->execute(array($lastId));
if ($row = $query->fetch()) {
- return $this->buildJob($row);
+ $jobId = $row['id'];
+ $job = $this->buildJob($row);
} else {
//begin at the start of the queue
$query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` ORDER BY `id` ASC', 1);
$query->execute();
if ($row = $query->fetch()) {
- return $this->buildJob($row);
+ $jobId = $row['id'];
+ $job = $this->buildJob($row);
} else {
return null; //empty job list
}
}
+ if (is_null($job)) {
+ $this->removeById($jobId);
+ return $this->getNext();
+ } else {
+ return $job;
+ }
}
/**