Completed
Push — stable10 ( b85e94...1e5021 )
by
unknown
23:18 queued 12:32
created
lib/private/BackgroundJob/TimedJob.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -32,26 +32,26 @@
 block discarded – undo
32 32
  * @package OC\BackgroundJob
33 33
  */
34 34
 abstract class TimedJob extends Job {
35
-	protected $interval = 0;
35
+    protected $interval = 0;
36 36
 
37
-	/**
38
-	 * set the interval for the job
39
-	 *
40
-	 * @param int $interval
41
-	 */
42
-	public function setInterval($interval) {
43
-		$this->interval = $interval;
44
-	}
37
+    /**
38
+     * set the interval for the job
39
+     *
40
+     * @param int $interval
41
+     */
42
+    public function setInterval($interval) {
43
+        $this->interval = $interval;
44
+    }
45 45
 
46
-	/**
47
-	 * run the job if
48
-	 *
49
-	 * @param JobList $jobList
50
-	 * @param ILogger $logger
51
-	 */
52
-	public function execute($jobList, ILogger $logger = null) {
53
-		if ((time() - $this->lastRun) > $this->interval) {
54
-			parent::execute($jobList, $logger);
55
-		}
56
-	}
46
+    /**
47
+     * run the job if
48
+     *
49
+     * @param JobList $jobList
50
+     * @param ILogger $logger
51
+     */
52
+    public function execute($jobList, ILogger $logger = null) {
53
+        if ((time() - $this->lastRun) > $this->interval) {
54
+            parent::execute($jobList, $logger);
55
+        }
56
+    }
57 57
 }
Please login to merge, or discard this patch.
lib/private/BackgroundJob/QueuedJob.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @package OC\BackgroundJob
33 33
  */
34 34
 abstract class QueuedJob extends Job {
35
-	/**
36
-	 * run the job, then remove it from the joblist
37
-	 *
38
-	 * @param JobList $jobList
39
-	 * @param ILogger $logger
40
-	 */
41
-	public function execute($jobList, ILogger $logger = null) {
42
-		$jobList->remove($this, $this->argument);
43
-		parent::execute($jobList, $logger);
44
-	}
35
+    /**
36
+     * run the job, then remove it from the joblist
37
+     *
38
+     * @param JobList $jobList
39
+     * @param ILogger $logger
40
+     */
41
+    public function execute($jobList, ILogger $logger = null) {
42
+        $jobList->remove($this, $this->argument);
43
+        parent::execute($jobList, $logger);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/private/BackgroundJob/Legacy/RegularJob.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@
 block discarded – undo
26 26
 use OCP\AutoloadNotAllowedException;
27 27
 
28 28
 class RegularJob extends \OC\BackgroundJob\Job {
29
-	public function run($argument) {
30
-		try {
31
-			if (is_callable($argument)) {
32
-				call_user_func($argument);
33
-			}
34
-		} catch (AutoloadNotAllowedException $e) {
35
-			// job is from a disabled app, ignore
36
-			return null;
37
-		}
38
-	}
29
+    public function run($argument) {
30
+        try {
31
+            if (is_callable($argument)) {
32
+                call_user_func($argument);
33
+            }
34
+        } catch (AutoloadNotAllowedException $e) {
35
+            // job is from a disabled app, ignore
36
+            return null;
37
+        }
38
+    }
39 39
 }
Please login to merge, or discard this patch.
lib/private/BackgroundJob/Legacy/QueuedJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@
 block discarded – undo
24 24
 namespace OC\BackgroundJob\Legacy;
25 25
 
26 26
 class QueuedJob extends \OC\BackgroundJob\QueuedJob {
27
-	public function run($argument) {
28
-		$class = $argument['klass'];
29
-		$method = $argument['method'];
30
-		$parameters = $argument['parameters'];
31
-		if (is_callable(array($class, $method))) {
32
-			call_user_func(array($class, $method), $parameters);
33
-		}
34
-	}
27
+    public function run($argument) {
28
+        $class = $argument['klass'];
29
+        $method = $argument['method'];
30
+        $parameters = $argument['parameters'];
31
+        if (is_callable(array($class, $method))) {
32
+            call_user_func(array($class, $method), $parameters);
33
+        }
34
+    }
35 35
 }
Please login to merge, or discard this patch.
lib/private/BackgroundJob/JobList.php 1 patch
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -36,280 +36,280 @@
 block discarded – undo
36 36
 
37 37
 class JobList implements IJobList {
38 38
 
39
-	/** @var IDBConnection */
40
-	protected $connection;
41
-
42
-	/**@var IConfig */
43
-	protected $config;
44
-
45
-	/**@var ITimeFactory */
46
-	protected $timeFactory;
47
-
48
-	/**
49
-	 * @param IDBConnection $connection
50
-	 * @param IConfig $config
51
-	 * @param ITimeFactory $timeFactory
52
-	 */
53
-	public function __construct(IDBConnection $connection, IConfig $config, ITimeFactory $timeFactory) {
54
-		$this->connection = $connection;
55
-		$this->config = $config;
56
-		$this->timeFactory = $timeFactory;
57
-	}
58
-
59
-	/**
60
-	 * @param IJob|string $job
61
-	 * @param mixed $argument
62
-	 */
63
-	public function add($job, $argument = null) {
64
-		if (!$this->has($job, $argument)) {
65
-			if ($job instanceof IJob) {
66
-				$class = get_class($job);
67
-			} else {
68
-				$class = $job;
69
-			}
70
-
71
-			$argument = json_encode($argument);
72
-			if (strlen($argument) > 4000) {
73
-				throw new \InvalidArgumentException('Background job arguments can\'t exceed 4000 characters (json encoded)');
74
-			}
75
-
76
-			$query = $this->connection->getQueryBuilder();
77
-			$query->insert('jobs')
78
-				->values([
79
-					'class' => $query->createNamedParameter($class),
80
-					'argument' => $query->createNamedParameter($argument),
81
-					'last_run' => $query->createNamedParameter(0, IQueryBuilder::PARAM_INT),
82
-					'last_checked' => $query->createNamedParameter($this->timeFactory->getTime(), IQueryBuilder::PARAM_INT),
83
-				]);
84
-			$query->execute();
85
-		}
86
-	}
87
-
88
-	/**
89
-	 * @param IJob|string $job
90
-	 * @param mixed $argument
91
-	 */
92
-	public function remove($job, $argument = null) {
93
-		if ($job instanceof IJob) {
94
-			$class = get_class($job);
95
-		} else {
96
-			$class = $job;
97
-		}
98
-
99
-		$query = $this->connection->getQueryBuilder();
100
-		$query->delete('jobs')
101
-			->where($query->expr()->eq('class', $query->createNamedParameter($class)));
102
-		if (!is_null($argument)) {
103
-			$argument = json_encode($argument);
104
-			$query->andWhere($query->expr()->eq('argument', $query->createNamedParameter($argument)));
105
-		}
106
-		$query->execute();
107
-	}
108
-
109
-	/**
110
-	 * @param int $id
111
-	 */
112
-	protected function removeById($id) {
113
-		$query = $this->connection->getQueryBuilder();
114
-		$query->delete('jobs')
115
-			->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
116
-		$query->execute();
117
-	}
118
-
119
-	/**
120
-	 * check if a job is in the list
121
-	 *
122
-	 * @param IJob|string $job
123
-	 * @param mixed $argument
124
-	 * @return bool
125
-	 */
126
-	public function has($job, $argument) {
127
-		if ($job instanceof IJob) {
128
-			$class = get_class($job);
129
-		} else {
130
-			$class = $job;
131
-		}
132
-		$argument = json_encode($argument);
133
-
134
-		$query = $this->connection->getQueryBuilder();
135
-		$query->select('id')
136
-			->from('jobs')
137
-			->where($query->expr()->eq('class', $query->createNamedParameter($class)))
138
-			->andWhere($query->expr()->eq('argument', $query->createNamedParameter($argument)))
139
-			->setMaxResults(1);
140
-
141
-		$result = $query->execute();
142
-		$row = $result->fetch();
143
-		$result->closeCursor();
144
-
145
-		return (bool) $row;
146
-	}
147
-
148
-	/**
149
-	 * get all jobs in the list
150
-	 *
151
-	 * @return IJob[]
152
-	 * @deprecated 9.0.0 - This method is dangerous since it can cause load and
153
-	 * memory problems when creating too many instances.
154
-	 */
155
-	public function getAll() {
156
-		$query = $this->connection->getQueryBuilder();
157
-		$query->select('*')
158
-			->from('jobs');
159
-		$result = $query->execute();
160
-
161
-		$jobs = [];
162
-		while ($row = $result->fetch()) {
163
-			$job = $this->buildJob($row);
164
-			if ($job) {
165
-				$jobs[] = $job;
166
-			}
167
-		}
168
-		$result->closeCursor();
169
-
170
-		return $jobs;
171
-	}
172
-
173
-	/**
174
-	 * get the next job in the list
175
-	 *
176
-	 * @return IJob|null
177
-	 */
178
-	public function getNext() {
179
-		$query = $this->connection->getQueryBuilder();
180
-		$query->select('*')
181
-			->from('jobs')
182
-			->where($query->expr()->lte('reserved_at', $query->createNamedParameter($this->timeFactory->getTime() - 12 * 3600, IQueryBuilder::PARAM_INT)))
183
-			->orderBy('last_checked', 'ASC')
184
-			->setMaxResults(1);
185
-
186
-		$update = $this->connection->getQueryBuilder();
187
-		$update->update('jobs')
188
-			->set('reserved_at', $update->createNamedParameter($this->timeFactory->getTime()))
189
-			->set('last_checked', $update->createNamedParameter($this->timeFactory->getTime()))
190
-			->where($update->expr()->eq('id', $update->createParameter('jobid')));
191
-
192
-		$this->connection->lockTable('jobs');
193
-		$result = $query->execute();
194
-		$row = $result->fetch();
195
-		$result->closeCursor();
196
-
197
-		if ($row) {
198
-			$update->setParameter('jobid', $row['id']);
199
-			$update->execute();
200
-			$this->connection->unlockTable();
201
-
202
-			$job = $this->buildJob($row);
203
-
204
-			if ($job === null) {
205
-				// Background job from disabled app, try again.
206
-				return $this->getNext();
207
-			}
208
-
209
-			return $job;
210
-		} else {
211
-			$this->connection->unlockTable();
212
-			return null;
213
-		}
214
-	}
215
-
216
-	/**
217
-	 * @param int $id
218
-	 * @return IJob|null
219
-	 */
220
-	public function getById($id) {
221
-		$query = $this->connection->getQueryBuilder();
222
-		$query->select('*')
223
-			->from('jobs')
224
-			->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
225
-		$result = $query->execute();
226
-		$row = $result->fetch();
227
-		$result->closeCursor();
228
-
229
-		if ($row) {
230
-			return $this->buildJob($row);
231
-		} else {
232
-			return null;
233
-		}
234
-	}
235
-
236
-	/**
237
-	 * get the job object from a row in the db
238
-	 *
239
-	 * @param array $row
240
-	 * @return IJob|null
241
-	 */
242
-	private function buildJob($row) {
243
-		try {
244
-			try {
245
-				// Try to load the job as a service
246
-				/** @var IJob $job */
247
-				$job = \OC::$server->query($row['class']);
248
-			} catch (QueryException $e) {
249
-				if (class_exists($row['class'])) {
250
-					$class = $row['class'];
251
-					$job = new $class();
252
-				} else {
253
-					// job from disabled app or old version of an app, no need to do anything
254
-					return null;
255
-				}
256
-			}
257
-
258
-			$job->setId($row['id']);
259
-			$job->setLastRun($row['last_run']);
260
-			$job->setArgument(json_decode($row['argument'], true));
261
-			return $job;
262
-		} catch (AutoloadNotAllowedException $e) {
263
-			// job is from a disabled app, ignore
264
-			return null;
265
-		}
266
-	}
267
-
268
-	/**
269
-	 * set the job that was last ran
270
-	 *
271
-	 * @param IJob $job
272
-	 */
273
-	public function setLastJob($job) {
274
-		$this->unlockJob($job);
275
-		$this->config->setAppValue('backgroundjob', 'lastjob', $job->getId());
276
-	}
277
-
278
-	/**
279
-	 * Remove the reservation for a job
280
-	 *
281
-	 * @param IJob $job
282
-	 */
283
-	public function unlockJob($job) {
284
-		$query = $this->connection->getQueryBuilder();
285
-		$query->update('jobs')
286
-			->set('reserved_at', $query->expr()->literal(0, IQueryBuilder::PARAM_INT))
287
-			->where($query->expr()->eq('id', $query->createNamedParameter($job->getId(), IQueryBuilder::PARAM_INT)));
288
-		$query->execute();
289
-	}
290
-
291
-	/**
292
-	 * get the id of the last ran job
293
-	 *
294
-	 * @return int
295
-	 * @deprecated 9.1.0 - The functionality behind the value is deprecated, it
296
-	 *    only tells you which job finished last, but since we now allow multiple
297
-	 *    executors to run in parallel, it's not used to calculate the next job.
298
-	 */
299
-	public function getLastJob() {
300
-		return (int) $this->config->getAppValue('backgroundjob', 'lastjob', 0);
301
-	}
302
-
303
-	/**
304
-	 * set the lastRun of $job to now
305
-	 *
306
-	 * @param IJob $job
307
-	 */
308
-	public function setLastRun($job) {
309
-		$query = $this->connection->getQueryBuilder();
310
-		$query->update('jobs')
311
-			->set('last_run', $query->createNamedParameter(time(), IQueryBuilder::PARAM_INT))
312
-			->where($query->expr()->eq('id', $query->createNamedParameter($job->getId(), IQueryBuilder::PARAM_INT)));
313
-		$query->execute();
314
-	}
39
+    /** @var IDBConnection */
40
+    protected $connection;
41
+
42
+    /**@var IConfig */
43
+    protected $config;
44
+
45
+    /**@var ITimeFactory */
46
+    protected $timeFactory;
47
+
48
+    /**
49
+     * @param IDBConnection $connection
50
+     * @param IConfig $config
51
+     * @param ITimeFactory $timeFactory
52
+     */
53
+    public function __construct(IDBConnection $connection, IConfig $config, ITimeFactory $timeFactory) {
54
+        $this->connection = $connection;
55
+        $this->config = $config;
56
+        $this->timeFactory = $timeFactory;
57
+    }
58
+
59
+    /**
60
+     * @param IJob|string $job
61
+     * @param mixed $argument
62
+     */
63
+    public function add($job, $argument = null) {
64
+        if (!$this->has($job, $argument)) {
65
+            if ($job instanceof IJob) {
66
+                $class = get_class($job);
67
+            } else {
68
+                $class = $job;
69
+            }
70
+
71
+            $argument = json_encode($argument);
72
+            if (strlen($argument) > 4000) {
73
+                throw new \InvalidArgumentException('Background job arguments can\'t exceed 4000 characters (json encoded)');
74
+            }
75
+
76
+            $query = $this->connection->getQueryBuilder();
77
+            $query->insert('jobs')
78
+                ->values([
79
+                    'class' => $query->createNamedParameter($class),
80
+                    'argument' => $query->createNamedParameter($argument),
81
+                    'last_run' => $query->createNamedParameter(0, IQueryBuilder::PARAM_INT),
82
+                    'last_checked' => $query->createNamedParameter($this->timeFactory->getTime(), IQueryBuilder::PARAM_INT),
83
+                ]);
84
+            $query->execute();
85
+        }
86
+    }
87
+
88
+    /**
89
+     * @param IJob|string $job
90
+     * @param mixed $argument
91
+     */
92
+    public function remove($job, $argument = null) {
93
+        if ($job instanceof IJob) {
94
+            $class = get_class($job);
95
+        } else {
96
+            $class = $job;
97
+        }
98
+
99
+        $query = $this->connection->getQueryBuilder();
100
+        $query->delete('jobs')
101
+            ->where($query->expr()->eq('class', $query->createNamedParameter($class)));
102
+        if (!is_null($argument)) {
103
+            $argument = json_encode($argument);
104
+            $query->andWhere($query->expr()->eq('argument', $query->createNamedParameter($argument)));
105
+        }
106
+        $query->execute();
107
+    }
108
+
109
+    /**
110
+     * @param int $id
111
+     */
112
+    protected function removeById($id) {
113
+        $query = $this->connection->getQueryBuilder();
114
+        $query->delete('jobs')
115
+            ->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
116
+        $query->execute();
117
+    }
118
+
119
+    /**
120
+     * check if a job is in the list
121
+     *
122
+     * @param IJob|string $job
123
+     * @param mixed $argument
124
+     * @return bool
125
+     */
126
+    public function has($job, $argument) {
127
+        if ($job instanceof IJob) {
128
+            $class = get_class($job);
129
+        } else {
130
+            $class = $job;
131
+        }
132
+        $argument = json_encode($argument);
133
+
134
+        $query = $this->connection->getQueryBuilder();
135
+        $query->select('id')
136
+            ->from('jobs')
137
+            ->where($query->expr()->eq('class', $query->createNamedParameter($class)))
138
+            ->andWhere($query->expr()->eq('argument', $query->createNamedParameter($argument)))
139
+            ->setMaxResults(1);
140
+
141
+        $result = $query->execute();
142
+        $row = $result->fetch();
143
+        $result->closeCursor();
144
+
145
+        return (bool) $row;
146
+    }
147
+
148
+    /**
149
+     * get all jobs in the list
150
+     *
151
+     * @return IJob[]
152
+     * @deprecated 9.0.0 - This method is dangerous since it can cause load and
153
+     * memory problems when creating too many instances.
154
+     */
155
+    public function getAll() {
156
+        $query = $this->connection->getQueryBuilder();
157
+        $query->select('*')
158
+            ->from('jobs');
159
+        $result = $query->execute();
160
+
161
+        $jobs = [];
162
+        while ($row = $result->fetch()) {
163
+            $job = $this->buildJob($row);
164
+            if ($job) {
165
+                $jobs[] = $job;
166
+            }
167
+        }
168
+        $result->closeCursor();
169
+
170
+        return $jobs;
171
+    }
172
+
173
+    /**
174
+     * get the next job in the list
175
+     *
176
+     * @return IJob|null
177
+     */
178
+    public function getNext() {
179
+        $query = $this->connection->getQueryBuilder();
180
+        $query->select('*')
181
+            ->from('jobs')
182
+            ->where($query->expr()->lte('reserved_at', $query->createNamedParameter($this->timeFactory->getTime() - 12 * 3600, IQueryBuilder::PARAM_INT)))
183
+            ->orderBy('last_checked', 'ASC')
184
+            ->setMaxResults(1);
185
+
186
+        $update = $this->connection->getQueryBuilder();
187
+        $update->update('jobs')
188
+            ->set('reserved_at', $update->createNamedParameter($this->timeFactory->getTime()))
189
+            ->set('last_checked', $update->createNamedParameter($this->timeFactory->getTime()))
190
+            ->where($update->expr()->eq('id', $update->createParameter('jobid')));
191
+
192
+        $this->connection->lockTable('jobs');
193
+        $result = $query->execute();
194
+        $row = $result->fetch();
195
+        $result->closeCursor();
196
+
197
+        if ($row) {
198
+            $update->setParameter('jobid', $row['id']);
199
+            $update->execute();
200
+            $this->connection->unlockTable();
201
+
202
+            $job = $this->buildJob($row);
203
+
204
+            if ($job === null) {
205
+                // Background job from disabled app, try again.
206
+                return $this->getNext();
207
+            }
208
+
209
+            return $job;
210
+        } else {
211
+            $this->connection->unlockTable();
212
+            return null;
213
+        }
214
+    }
215
+
216
+    /**
217
+     * @param int $id
218
+     * @return IJob|null
219
+     */
220
+    public function getById($id) {
221
+        $query = $this->connection->getQueryBuilder();
222
+        $query->select('*')
223
+            ->from('jobs')
224
+            ->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
225
+        $result = $query->execute();
226
+        $row = $result->fetch();
227
+        $result->closeCursor();
228
+
229
+        if ($row) {
230
+            return $this->buildJob($row);
231
+        } else {
232
+            return null;
233
+        }
234
+    }
235
+
236
+    /**
237
+     * get the job object from a row in the db
238
+     *
239
+     * @param array $row
240
+     * @return IJob|null
241
+     */
242
+    private function buildJob($row) {
243
+        try {
244
+            try {
245
+                // Try to load the job as a service
246
+                /** @var IJob $job */
247
+                $job = \OC::$server->query($row['class']);
248
+            } catch (QueryException $e) {
249
+                if (class_exists($row['class'])) {
250
+                    $class = $row['class'];
251
+                    $job = new $class();
252
+                } else {
253
+                    // job from disabled app or old version of an app, no need to do anything
254
+                    return null;
255
+                }
256
+            }
257
+
258
+            $job->setId($row['id']);
259
+            $job->setLastRun($row['last_run']);
260
+            $job->setArgument(json_decode($row['argument'], true));
261
+            return $job;
262
+        } catch (AutoloadNotAllowedException $e) {
263
+            // job is from a disabled app, ignore
264
+            return null;
265
+        }
266
+    }
267
+
268
+    /**
269
+     * set the job that was last ran
270
+     *
271
+     * @param IJob $job
272
+     */
273
+    public function setLastJob($job) {
274
+        $this->unlockJob($job);
275
+        $this->config->setAppValue('backgroundjob', 'lastjob', $job->getId());
276
+    }
277
+
278
+    /**
279
+     * Remove the reservation for a job
280
+     *
281
+     * @param IJob $job
282
+     */
283
+    public function unlockJob($job) {
284
+        $query = $this->connection->getQueryBuilder();
285
+        $query->update('jobs')
286
+            ->set('reserved_at', $query->expr()->literal(0, IQueryBuilder::PARAM_INT))
287
+            ->where($query->expr()->eq('id', $query->createNamedParameter($job->getId(), IQueryBuilder::PARAM_INT)));
288
+        $query->execute();
289
+    }
290
+
291
+    /**
292
+     * get the id of the last ran job
293
+     *
294
+     * @return int
295
+     * @deprecated 9.1.0 - The functionality behind the value is deprecated, it
296
+     *    only tells you which job finished last, but since we now allow multiple
297
+     *    executors to run in parallel, it's not used to calculate the next job.
298
+     */
299
+    public function getLastJob() {
300
+        return (int) $this->config->getAppValue('backgroundjob', 'lastjob', 0);
301
+    }
302
+
303
+    /**
304
+     * set the lastRun of $job to now
305
+     *
306
+     * @param IJob $job
307
+     */
308
+    public function setLastRun($job) {
309
+        $query = $this->connection->getQueryBuilder();
310
+        $query->update('jobs')
311
+            ->set('last_run', $query->createNamedParameter(time(), IQueryBuilder::PARAM_INT))
312
+            ->where($query->expr()->eq('id', $query->createNamedParameter($job->getId(), IQueryBuilder::PARAM_INT)));
313
+        $query->execute();
314
+    }
315 315
 }
Please login to merge, or discard this patch.
lib/private/BackgroundJob/Job.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -28,62 +28,62 @@
 block discarded – undo
28 28
 use OCP\ILogger;
29 29
 
30 30
 abstract class Job implements IJob {
31
-	/**
32
-	 * @var int $id
33
-	 */
34
-	protected $id;
31
+    /**
32
+     * @var int $id
33
+     */
34
+    protected $id;
35 35
 
36
-	/**
37
-	 * @var int $lastRun
38
-	 */
39
-	protected $lastRun;
36
+    /**
37
+     * @var int $lastRun
38
+     */
39
+    protected $lastRun;
40 40
 
41
-	/**
42
-	 * @var mixed $argument
43
-	 */
44
-	protected $argument;
41
+    /**
42
+     * @var mixed $argument
43
+     */
44
+    protected $argument;
45 45
 
46
-	/**
47
-	 * @param JobList $jobList
48
-	 * @param ILogger $logger
49
-	 */
50
-	public function execute($jobList, ILogger $logger = null) {
51
-		$jobList->setLastRun($this);
52
-		try {
53
-			$this->run($this->argument);
54
-		} catch (\Exception $e) {
55
-			if ($logger) {
56
-				$logger->logException($e, [
57
-					'app' => 'core',
58
-					'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')'
59
-				]);
60
-			}
61
-		}
62
-	}
46
+    /**
47
+     * @param JobList $jobList
48
+     * @param ILogger $logger
49
+     */
50
+    public function execute($jobList, ILogger $logger = null) {
51
+        $jobList->setLastRun($this);
52
+        try {
53
+            $this->run($this->argument);
54
+        } catch (\Exception $e) {
55
+            if ($logger) {
56
+                $logger->logException($e, [
57
+                    'app' => 'core',
58
+                    'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')'
59
+                ]);
60
+            }
61
+        }
62
+    }
63 63
 
64
-	abstract protected function run($argument);
64
+    abstract protected function run($argument);
65 65
 
66
-	public function setId($id) {
67
-		$this->id = $id;
68
-	}
66
+    public function setId($id) {
67
+        $this->id = $id;
68
+    }
69 69
 
70
-	public function setLastRun($lastRun) {
71
-		$this->lastRun = $lastRun;
72
-	}
70
+    public function setLastRun($lastRun) {
71
+        $this->lastRun = $lastRun;
72
+    }
73 73
 
74
-	public function setArgument($argument) {
75
-		$this->argument = $argument;
76
-	}
74
+    public function setArgument($argument) {
75
+        $this->argument = $argument;
76
+    }
77 77
 
78
-	public function getId() {
79
-		return $this->id;
80
-	}
78
+    public function getId() {
79
+        return $this->id;
80
+    }
81 81
 
82
-	public function getLastRun() {
83
-		return $this->lastRun;
84
-	}
82
+    public function getLastRun() {
83
+        return $this->lastRun;
84
+    }
85 85
 
86
-	public function getArgument() {
87
-		return $this->argument;
88
-	}
86
+    public function getArgument() {
87
+        return $this->argument;
88
+    }
89 89
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 			if ($logger) {
56 56
 				$logger->logException($e, [
57 57
 					'app' => 'core',
58
-					'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')'
58
+					'message' => 'Error while running background job (class: '.get_class($this).', arguments: '.print_r($this->argument, true).')'
59 59
 				]);
60 60
 			}
61 61
 		}
Please login to merge, or discard this patch.
lib/private/Settings/Admin/TipsTricks.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -28,44 +28,44 @@
 block discarded – undo
28 28
 use OCP\Settings\ISettings;
29 29
 
30 30
 class TipsTricks implements ISettings {
31
-	/** @var IConfig */
32
-	private $config;
31
+    /** @var IConfig */
32
+    private $config;
33 33
 
34
-	/**
35
-	 * @param IConfig $config
36
-	 */
37
-	public function __construct(IConfig $config) {
38
-		$this->config = $config;
39
-	}
34
+    /**
35
+     * @param IConfig $config
36
+     */
37
+    public function __construct(IConfig $config) {
38
+        $this->config = $config;
39
+    }
40 40
 
41
-	/**
42
-	 * @return TemplateResponse
43
-	 */
44
-	public function getForm() {
45
-		$databaseOverload = (strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false);
41
+    /**
42
+     * @return TemplateResponse
43
+     */
44
+    public function getForm() {
45
+        $databaseOverload = (strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false);
46 46
 
47
-		$parameters = [
48
-			'databaseOverload' => $databaseOverload,
49
-		];
47
+        $parameters = [
48
+            'databaseOverload' => $databaseOverload,
49
+        ];
50 50
 
51
-		return new TemplateResponse('settings', 'admin/tipstricks', $parameters, '');
52
-	}
51
+        return new TemplateResponse('settings', 'admin/tipstricks', $parameters, '');
52
+    }
53 53
 
54
-	/**
55
-	 * @return string the section ID, e.g. 'sharing'
56
-	 */
57
-	public function getSection() {
58
-		return 'tips-tricks';
59
-	}
54
+    /**
55
+     * @return string the section ID, e.g. 'sharing'
56
+     */
57
+    public function getSection() {
58
+        return 'tips-tricks';
59
+    }
60 60
 
61
-	/**
62
-	 * @return int whether the form should be rather on the top or bottom of
63
-	 * the admin section. The forms are arranged in ascending order of the
64
-	 * priority values. It is required to return a value between 0 and 100.
65
-	 *
66
-	 * E.g.: 70
67
-	 */
68
-	public function getPriority() {
69
-		return 0;
70
-	}
61
+    /**
62
+     * @return int whether the form should be rather on the top or bottom of
63
+     * the admin section. The forms are arranged in ascending order of the
64
+     * priority values. It is required to return a value between 0 and 100.
65
+     *
66
+     * E.g.: 70
67
+     */
68
+    public function getPriority() {
69
+        return 0;
70
+    }
71 71
 }
Please login to merge, or discard this patch.
lib/private/Settings/Admin/Additional.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -36,53 +36,53 @@
 block discarded – undo
36 36
 use OCP\Settings\ISettings;
37 37
 
38 38
 class Additional implements ISettings {
39
-	/** @var IConfig */
40
-	private $config;
39
+    /** @var IConfig */
40
+    private $config;
41 41
 
42
-	/**
43
-	 * @param IConfig $config
44
-	 */
45
-	public function __construct(IConfig $config) {
46
-		$this->config = $config;
47
-	}
42
+    /**
43
+     * @param IConfig $config
44
+     */
45
+    public function __construct(IConfig $config) {
46
+        $this->config = $config;
47
+    }
48 48
 
49
-	/**
50
-	 * @return TemplateResponse
51
-	 */
52
-	public function getForm() {
53
-		$parameters = [
54
-			// Mail
55
-			'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
56
-			'mail_domain'           => $this->config->getSystemValue('mail_domain', ''),
57
-			'mail_from_address'     => $this->config->getSystemValue('mail_from_address', ''),
58
-			'mail_smtpmode'         => $this->config->getSystemValue('mail_smtpmode', ''),
59
-			'mail_smtpsecure'       => $this->config->getSystemValue('mail_smtpsecure', ''),
60
-			'mail_smtphost'         => $this->config->getSystemValue('mail_smtphost', ''),
61
-			'mail_smtpport'         => $this->config->getSystemValue('mail_smtpport', ''),
62
-			'mail_smtpauthtype'     => $this->config->getSystemValue('mail_smtpauthtype', ''),
63
-			'mail_smtpauth'         => $this->config->getSystemValue('mail_smtpauth', false),
64
-			'mail_smtpname'         => $this->config->getSystemValue('mail_smtpname', ''),
65
-			'mail_smtppassword'     => $this->config->getSystemValue('mail_smtppassword', ''),
66
-		];
49
+    /**
50
+     * @return TemplateResponse
51
+     */
52
+    public function getForm() {
53
+        $parameters = [
54
+            // Mail
55
+            'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
56
+            'mail_domain'           => $this->config->getSystemValue('mail_domain', ''),
57
+            'mail_from_address'     => $this->config->getSystemValue('mail_from_address', ''),
58
+            'mail_smtpmode'         => $this->config->getSystemValue('mail_smtpmode', ''),
59
+            'mail_smtpsecure'       => $this->config->getSystemValue('mail_smtpsecure', ''),
60
+            'mail_smtphost'         => $this->config->getSystemValue('mail_smtphost', ''),
61
+            'mail_smtpport'         => $this->config->getSystemValue('mail_smtpport', ''),
62
+            'mail_smtpauthtype'     => $this->config->getSystemValue('mail_smtpauthtype', ''),
63
+            'mail_smtpauth'         => $this->config->getSystemValue('mail_smtpauth', false),
64
+            'mail_smtpname'         => $this->config->getSystemValue('mail_smtpname', ''),
65
+            'mail_smtppassword'     => $this->config->getSystemValue('mail_smtppassword', ''),
66
+        ];
67 67
 
68
-		return new TemplateResponse('settings', 'admin/additional-mail', $parameters, '');
69
-	}
68
+        return new TemplateResponse('settings', 'admin/additional-mail', $parameters, '');
69
+    }
70 70
 
71
-	/**
72
-	 * @return string the section ID, e.g. 'sharing'
73
-	 */
74
-	public function getSection() {
75
-		return 'additional';
76
-	}
71
+    /**
72
+     * @return string the section ID, e.g. 'sharing'
73
+     */
74
+    public function getSection() {
75
+        return 'additional';
76
+    }
77 77
 
78
-	/**
79
-	 * @return int whether the form should be rather on the top or bottom of
80
-	 * the admin section. The forms are arranged in ascending order of the
81
-	 * priority values. It is required to return a value between 0 and 100.
82
-	 *
83
-	 * E.g.: 70
84
-	 */
85
-	public function getPriority() {
86
-		return 0;
87
-	}
78
+    /**
79
+     * @return int whether the form should be rather on the top or bottom of
80
+     * the admin section. The forms are arranged in ascending order of the
81
+     * priority values. It is required to return a value between 0 and 100.
82
+     *
83
+     * E.g.: 70
84
+     */
85
+    public function getPriority() {
86
+        return 0;
87
+    }
88 88
 }
Please login to merge, or discard this patch.
lib/private/Settings/RemoveOrphaned.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -36,56 +36,56 @@
 block discarded – undo
36 36
  */
37 37
 class RemoveOrphaned extends TimedJob {
38 38
 
39
-	/** @var IJobList */
40
-	private $jobList;
39
+    /** @var IJobList */
40
+    private $jobList;
41 41
 
42
-	/** @var ILogger */
43
-	private $logger;
42
+    /** @var ILogger */
43
+    private $logger;
44 44
 
45
-	/** @var Manager */
46
-	private $manager;
45
+    /** @var Manager */
46
+    private $manager;
47 47
 
48
-	public function __construct(Manager $manager = null) {
49
-		if($manager !== null) {
50
-			$this->manager = $manager;
51
-		} else {
52
-			// fix DI for Jobs
53
-			$this->manager = \OC::$server->getSettingsManager();
54
-		}
55
-	}
48
+    public function __construct(Manager $manager = null) {
49
+        if($manager !== null) {
50
+            $this->manager = $manager;
51
+        } else {
52
+            // fix DI for Jobs
53
+            $this->manager = \OC::$server->getSettingsManager();
54
+        }
55
+    }
56 56
 
57
-	/**
58
-	 * run the job, then remove it from the job list
59
-	 *
60
-	 * @param JobList $jobList
61
-	 * @param ILogger $logger
62
-	 */
63
-	public function execute($jobList, ILogger $logger = null) {
64
-		// add an interval of 15 mins
65
-		$this->setInterval(15*60);
57
+    /**
58
+     * run the job, then remove it from the job list
59
+     *
60
+     * @param JobList $jobList
61
+     * @param ILogger $logger
62
+     */
63
+    public function execute($jobList, ILogger $logger = null) {
64
+        // add an interval of 15 mins
65
+        $this->setInterval(15*60);
66 66
 
67
-		$this->jobList = $jobList;
68
-		$this->logger = $logger;
69
-		parent::execute($jobList, $logger);
70
-	}
67
+        $this->jobList = $jobList;
68
+        $this->logger = $logger;
69
+        parent::execute($jobList, $logger);
70
+    }
71 71
 
72
-	/**
73
-	 * @param array $argument
74
-	 * @throws \Exception
75
-	 * @throws \OC\NeedsUpdateException
76
-	 */
77
-	protected function run($argument) {
78
-		try {
79
-			\OC_App::loadApps();
80
-		} catch (NeedsUpdateException $ex) {
81
-			// only run when apps are up to date
82
-			return;
83
-		}
72
+    /**
73
+     * @param array $argument
74
+     * @throws \Exception
75
+     * @throws \OC\NeedsUpdateException
76
+     */
77
+    protected function run($argument) {
78
+        try {
79
+            \OC_App::loadApps();
80
+        } catch (NeedsUpdateException $ex) {
81
+            // only run when apps are up to date
82
+            return;
83
+        }
84 84
 
85
-		$this->manager->checkForOrphanedClassNames();
85
+        $this->manager->checkForOrphanedClassNames();
86 86
 
87
-		// remove the job once executed successfully
88
-		$this->jobList->remove($this);
89
-	}
87
+        // remove the job once executed successfully
88
+        $this->jobList->remove($this);
89
+    }
90 90
 
91 91
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	private $manager;
47 47
 
48 48
 	public function __construct(Manager $manager = null) {
49
-		if($manager !== null) {
49
+		if ($manager !== null) {
50 50
 			$this->manager = $manager;
51 51
 		} else {
52 52
 			// fix DI for Jobs
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function execute($jobList, ILogger $logger = null) {
64 64
 		// add an interval of 15 mins
65
-		$this->setInterval(15*60);
65
+		$this->setInterval(15 * 60);
66 66
 
67 67
 		$this->jobList = $jobList;
68 68
 		$this->logger = $logger;
Please login to merge, or discard this patch.