fix: delete background jobs by id when cleaning up

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2024-05-30 15:07:26 +02:00 committed by backportbot[bot]
parent 635f83cc73
commit b76f4fb2ea
3 changed files with 14 additions and 2 deletions

View file

@ -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)));

View file

@ -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
*

View file

@ -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);
}
}