diff options
Diffstat (limited to 'lib/private/backgroundjob/joblist.php')
-rw-r--r-- | lib/private/backgroundjob/joblist.php | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php index 75c205833fe..3618b0f9e5e 100644 --- a/lib/private/backgroundjob/joblist.php +++ b/lib/private/backgroundjob/joblist.php @@ -24,6 +24,7 @@ namespace OC\BackgroundJob; +use OCP\AppFramework\QueryException; use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\IJobList; use OCP\AutoloadNotAllowedException; @@ -232,24 +233,29 @@ class JobList implements IJobList { * @return IJob|null */ private function buildJob($row) { - $class = $row['class']; - /** - * @var Job $job - */ try { - if (!class_exists($class)) { - // job from disabled app or old version of an app, no need to do anything - return null; + try { + // Try to load the job as a service + /** @var Job $job */ + $job = \OC::$server->query($row['class']); + } catch (QueryException $e) { + if (class_exists($row['class'])) { + $class = $row['class']; + $job = new $class(); + } else { + // job from disabled app or old version of an app, no need to do anything + return null; + } } - $job = new $class(); + $job->setId($row['id']); $job->setLastRun($row['last_run']); $job->setArgument(json_decode($row['argument'], true)); return $job; } catch (AutoloadNotAllowedException $e) { // job is from a disabled app, ignore + return null; } - return null; } /** |