summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-12-18 11:44:32 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-12-18 14:20:30 +0100
commit0daed65e1466cc96584b5043795678ade0698fb0 (patch)
tree1b482f4bc44e87a2b88ee3e0245f3ad86a4a4f11 /lib
parent1f197134c87836167142cc766bdaab572fb73b8d (diff)
downloadnextcloud-server-0daed65e1466cc96584b5043795678ade0698fb0.tar.gz
nextcloud-server-0daed65e1466cc96584b5043795678ade0698fb0.zip
Allow dependency injection for background jobs
Diffstat (limited to 'lib')
-rw-r--r--lib/private/backgroundjob/joblist.php24
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;
}
/**