diff options
author | Robin Appelman <robin@icewind.nl> | 2024-05-30 15:07:26 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-05-30 15:07:26 +0200 |
commit | 1a9f7d5348c74b81733983570864b943afd06994 (patch) | |
tree | b0c3194ee94b50405e61eda8351ce3a47f541a28 | |
parent | 0eb74d70880920b7f1c0008dadea2e8169aa545a (diff) | |
download | nextcloud-server-1a9f7d5348c74b81733983570864b943afd06994.tar.gz nextcloud-server-1a9f7d5348c74b81733983570864b943afd06994.zip |
fix: delete background jobs by id when cleaning up
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/BackgroundJob/JobList.php | 2 | ||||
-rw-r--r-- | lib/public/BackgroundJob/IJobList.php | 8 | ||||
-rw-r--r-- | lib/public/BackgroundJob/QueuedJob.php | 6 |
3 files changed, 14 insertions, 2 deletions
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php index 3df9be7558c..61c48b0eab2 100644 --- a/lib/private/BackgroundJob/JobList.php +++ b/lib/private/BackgroundJob/JobList.php @@ -113,7 +113,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 dbe154ff5f8..c082ef22f2f 100644 --- a/lib/public/BackgroundJob/IJobList.php +++ b/lib/public/BackgroundJob/IJobList.php @@ -61,6 +61,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 c75948d1a11..caacff42b1a 100644 --- a/lib/public/BackgroundJob/QueuedJob.php +++ b/lib/public/BackgroundJob/QueuedJob.php @@ -35,7 +35,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); } } |