@@ -36,14 +36,14 @@ |
||
36 | 36 | * @deprecated internal class, use \OCP\BackgroundJob\QueuedJob |
37 | 37 | */ |
38 | 38 | abstract class QueuedJob extends Job { |
39 | - /** |
|
40 | - * run the job, then remove it from the joblist |
|
41 | - * |
|
42 | - * @param JobList $jobList |
|
43 | - * @param ILogger|null $logger |
|
44 | - */ |
|
45 | - public function execute($jobList, ILogger $logger = null) { |
|
46 | - $jobList->remove($this, $this->argument); |
|
47 | - parent::execute($jobList, $logger); |
|
48 | - } |
|
39 | + /** |
|
40 | + * run the job, then remove it from the joblist |
|
41 | + * |
|
42 | + * @param JobList $jobList |
|
43 | + * @param ILogger|null $logger |
|
44 | + */ |
|
45 | + public function execute($jobList, ILogger $logger = null) { |
|
46 | + $jobList->remove($this, $this->argument); |
|
47 | + parent::execute($jobList, $logger); |
|
48 | + } |
|
49 | 49 | } |
@@ -38,26 +38,26 @@ |
||
38 | 38 | * @deprecated internal class, use \OCP\BackgroundJob\TimedJob |
39 | 39 | */ |
40 | 40 | abstract class TimedJob extends Job { |
41 | - protected $interval = 0; |
|
41 | + protected $interval = 0; |
|
42 | 42 | |
43 | - /** |
|
44 | - * set the interval for the job |
|
45 | - * |
|
46 | - * @param int $interval |
|
47 | - */ |
|
48 | - public function setInterval($interval) { |
|
49 | - $this->interval = $interval; |
|
50 | - } |
|
43 | + /** |
|
44 | + * set the interval for the job |
|
45 | + * |
|
46 | + * @param int $interval |
|
47 | + */ |
|
48 | + public function setInterval($interval) { |
|
49 | + $this->interval = $interval; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * run the job if |
|
54 | - * |
|
55 | - * @param IJobList $jobList |
|
56 | - * @param ILogger|null $logger |
|
57 | - */ |
|
58 | - public function execute($jobList, ILogger $logger = null) { |
|
59 | - if ((time() - $this->lastRun) > $this->interval) { |
|
60 | - parent::execute($jobList, $logger); |
|
61 | - } |
|
62 | - } |
|
52 | + /** |
|
53 | + * run the job if |
|
54 | + * |
|
55 | + * @param IJobList $jobList |
|
56 | + * @param ILogger|null $logger |
|
57 | + */ |
|
58 | + public function execute($jobList, ILogger $logger = null) { |
|
59 | + if ((time() - $this->lastRun) > $this->interval) { |
|
60 | + parent::execute($jobList, $logger); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | } |
@@ -33,62 +33,62 @@ |
||
33 | 33 | * @deprecated internal class, use \OCP\BackgroundJob\Job |
34 | 34 | */ |
35 | 35 | abstract class Job implements IJob { |
36 | - /** @var int */ |
|
37 | - protected $id; |
|
36 | + /** @var int */ |
|
37 | + protected $id; |
|
38 | 38 | |
39 | - /** @var int */ |
|
40 | - protected $lastRun; |
|
39 | + /** @var int */ |
|
40 | + protected $lastRun; |
|
41 | 41 | |
42 | - /** @var mixed */ |
|
43 | - protected $argument; |
|
42 | + /** @var mixed */ |
|
43 | + protected $argument; |
|
44 | 44 | |
45 | - public function execute(IJobList $jobList, ILogger $logger = null) { |
|
46 | - $jobList->setLastRun($this); |
|
47 | - if ($logger === null) { |
|
48 | - $logger = \OC::$server->getLogger(); |
|
49 | - } |
|
45 | + public function execute(IJobList $jobList, ILogger $logger = null) { |
|
46 | + $jobList->setLastRun($this); |
|
47 | + if ($logger === null) { |
|
48 | + $logger = \OC::$server->getLogger(); |
|
49 | + } |
|
50 | 50 | |
51 | - try { |
|
52 | - $jobStartTime = time(); |
|
53 | - $logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']); |
|
54 | - $this->run($this->argument); |
|
55 | - $timeTaken = time() - $jobStartTime; |
|
51 | + try { |
|
52 | + $jobStartTime = time(); |
|
53 | + $logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']); |
|
54 | + $this->run($this->argument); |
|
55 | + $timeTaken = time() - $jobStartTime; |
|
56 | 56 | |
57 | - $logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']); |
|
58 | - $jobList->setExecutionTime($this, $timeTaken); |
|
59 | - } catch (\Throwable $e) { |
|
60 | - if ($logger) { |
|
61 | - $logger->logException($e, [ |
|
62 | - 'app' => 'core', |
|
63 | - 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')' |
|
64 | - ]); |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
57 | + $logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']); |
|
58 | + $jobList->setExecutionTime($this, $timeTaken); |
|
59 | + } catch (\Throwable $e) { |
|
60 | + if ($logger) { |
|
61 | + $logger->logException($e, [ |
|
62 | + 'app' => 'core', |
|
63 | + 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')' |
|
64 | + ]); |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - abstract protected function run($argument); |
|
69 | + abstract protected function run($argument); |
|
70 | 70 | |
71 | - public function setId(int $id) { |
|
72 | - $this->id = $id; |
|
73 | - } |
|
71 | + public function setId(int $id) { |
|
72 | + $this->id = $id; |
|
73 | + } |
|
74 | 74 | |
75 | - public function setLastRun(int $lastRun) { |
|
76 | - $this->lastRun = $lastRun; |
|
77 | - } |
|
75 | + public function setLastRun(int $lastRun) { |
|
76 | + $this->lastRun = $lastRun; |
|
77 | + } |
|
78 | 78 | |
79 | - public function setArgument($argument) { |
|
80 | - $this->argument = $argument; |
|
81 | - } |
|
79 | + public function setArgument($argument) { |
|
80 | + $this->argument = $argument; |
|
81 | + } |
|
82 | 82 | |
83 | - public function getId() { |
|
84 | - return $this->id; |
|
85 | - } |
|
83 | + public function getId() { |
|
84 | + return $this->id; |
|
85 | + } |
|
86 | 86 | |
87 | - public function getLastRun() { |
|
88 | - return $this->lastRun; |
|
89 | - } |
|
87 | + public function getLastRun() { |
|
88 | + return $this->lastRun; |
|
89 | + } |
|
90 | 90 | |
91 | - public function getArgument() { |
|
92 | - return $this->argument; |
|
93 | - } |
|
91 | + public function getArgument() { |
|
92 | + return $this->argument; |
|
93 | + } |
|
94 | 94 | } |
@@ -27,12 +27,12 @@ |
||
27 | 27 | * @deprecated internal class, use \OCP\BackgroundJob\QueuedJob |
28 | 28 | */ |
29 | 29 | class QueuedJob extends \OC\BackgroundJob\QueuedJob { |
30 | - public function run($argument) { |
|
31 | - $class = $argument['klass']; |
|
32 | - $method = $argument['method']; |
|
33 | - $parameters = $argument['parameters']; |
|
34 | - if (is_callable([$class, $method])) { |
|
35 | - call_user_func([$class, $method], $parameters); |
|
36 | - } |
|
37 | - } |
|
30 | + public function run($argument) { |
|
31 | + $class = $argument['klass']; |
|
32 | + $method = $argument['method']; |
|
33 | + $parameters = $argument['parameters']; |
|
34 | + if (is_callable([$class, $method])) { |
|
35 | + call_user_func([$class, $method], $parameters); |
|
36 | + } |
|
37 | + } |
|
38 | 38 | } |
@@ -28,14 +28,14 @@ |
||
28 | 28 | * @deprecated internal class, use \OCP\BackgroundJob\QueuedJob |
29 | 29 | */ |
30 | 30 | class RegularJob extends \OC\BackgroundJob\Job { |
31 | - public function run($argument) { |
|
32 | - try { |
|
33 | - if (is_callable($argument)) { |
|
34 | - call_user_func($argument); |
|
35 | - } |
|
36 | - } catch (AutoloadNotAllowedException $e) { |
|
37 | - // job is from a disabled app, ignore |
|
38 | - return null; |
|
39 | - } |
|
40 | - } |
|
31 | + public function run($argument) { |
|
32 | + try { |
|
33 | + if (is_callable($argument)) { |
|
34 | + call_user_func($argument); |
|
35 | + } |
|
36 | + } catch (AutoloadNotAllowedException $e) { |
|
37 | + // job is from a disabled app, ignore |
|
38 | + return null; |
|
39 | + } |
|
40 | + } |
|
41 | 41 | } |