diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php index ae214f69509..2f98dd4c896 100644 --- a/lib/private/BackgroundJob/JobList.php +++ b/lib/private/BackgroundJob/JobList.php @@ -127,7 +127,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 a0f32cb0359..144c2195768 100644 --- a/lib/public/BackgroundJob/IJobList.php +++ b/lib/public/BackgroundJob/IJobList.php @@ -66,6 +66,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 * 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); } }