]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check background job type 32666/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Tue, 31 May 2022 06:31:38 +0000 (08:31 +0200)
committerJohn Molakvoæ (Rebase PR Action) <skjnldsv@users.noreply.github.com>
Tue, 31 May 2022 15:24:30 +0000 (15:24 +0000)
It is assumed that a job class loaded from the jobs table is an IJob,
but due to programming error the job might be of another type. Then the
setters will most likely fail.

This patch adds an interface type check so only correct jobs are used,
anything else is ignored.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
lib/private/BackgroundJob/JobList.php

index fe65a1879bcc49b8b2662d3a39d1f104f1356bb6..7ab86df84556a5e1c96d9759fa8b950819c5b735 100644 (file)
@@ -311,6 +311,10 @@ class JobList implements IJobList {
                                }
                        }
 
+                       if (!($job instanceof IJob)) {
+                               // This most likely means an invalid job was enqueued. We can ignore it.
+                               return null;
+                       }
                        $job->setId((int) $row['id']);
                        $job->setLastRun((int) $row['last_run']);
                        $job->setArgument(json_decode($row['argument'], true));