Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: delete background jobs by id when cleaning up
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and AndyScherzinger committed Jul 10, 2024
commit 7a801f0690a7d00e31e4155cb286ceb93feb1262
2 changes: 1 addition & 1 deletion lib/private/BackgroundJob/JobList.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function remove($job, $argument = null): void {
}
}

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)));
Expand Down
8 changes: 8 additions & 0 deletions lib/public/BackgroundJob/IJobList.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ public function scheduleAfter(string $job, int $runAfter, $argument = null): voi
*/
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
*
Expand Down
6 changes: 5 additions & 1 deletion lib/public/BackgroundJob/QueuedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ final public function execute($jobList, ?ILogger $logger = null) {
* @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);
}
}