aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-05-30 15:07:26 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-06-17 11:23:24 +0000
commit40442f533701380c6ef68d69cb818e1211ad20c4 (patch)
tree59eb831cfddc425b244982b9cb5f851ac8ccc2f6 /lib
parent78fd195e6a78f1c58f3f9ec4189ca910bd0b3eab (diff)
downloadnextcloud-server-40442f533701380c6ef68d69cb818e1211ad20c4.tar.gz
nextcloud-server-40442f533701380c6ef68d69cb818e1211ad20c4.zip
fix: delete background jobs by id when cleaning up
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/BackgroundJob/JobList.php2
-rw-r--r--lib/public/BackgroundJob/IJobList.php8
-rw-r--r--lib/public/BackgroundJob/QueuedJob.php6
3 files changed, 14 insertions, 2 deletions
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php
index 3ec2e0af1b3..77c25526fb8 100644
--- a/lib/private/BackgroundJob/JobList.php
+++ b/lib/private/BackgroundJob/JobList.php
@@ -135,7 +135,7 @@ class JobList implements IJobList {
}
}
- protected function removeById(int $id): void {
+ public function removeById(int $id): void {
$query = $this->connection->getQueryBuilder();
$query->delete('jobs')
->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
diff --git a/lib/public/BackgroundJob/IJobList.php b/lib/public/BackgroundJob/IJobList.php
index 0b00326ca1a..d9efd3828f4 100644
--- a/lib/public/BackgroundJob/IJobList.php
+++ b/lib/public/BackgroundJob/IJobList.php
@@ -80,6 +80,14 @@ interface IJobList {
public function remove($job, $argument = null): void;
/**
+ * Remove a job from the list by id
+ *
+ * @param int $id
+ * @since 30.0.0
+ */
+ public function removeById(int $id): void;
+
+ /**
* check if a job is in the list
*
* @param IJob|class-string<IJob> $job
diff --git a/lib/public/BackgroundJob/QueuedJob.php b/lib/public/BackgroundJob/QueuedJob.php
index e93db3420b8..2b5b67f2b66 100644
--- a/lib/public/BackgroundJob/QueuedJob.php
+++ b/lib/public/BackgroundJob/QueuedJob.php
@@ -53,7 +53,11 @@ abstract class QueuedJob extends Job {
* @since 25.0.0
*/
final public function start(IJobList $jobList): void {
- $jobList->remove($this, $this->argument);
+ if ($this->id) {
+ $jobList->removeById($this->id);
+ } else {
+ $jobList->remove($this, $this->argument);
+ }
parent::start($jobList);
}
}