Completed
Push — master ( 49a025...016f2f )
by
unknown
60:07 queued 24:26
created
cron.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * SPDX-License-Identifier: AGPL-3.0-only
14 14
  */
15 15
 
16
-require_once __DIR__ . '/lib/versioncheck.php';
16
+require_once __DIR__.'/lib/versioncheck.php';
17 17
 
18 18
 use OCP\App\IAppManager;
19 19
 use OCP\BackgroundJob\IJobList;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 use Psr\Log\LoggerInterface;
27 27
 
28 28
 try {
29
-	require_once __DIR__ . '/lib/base.php';
29
+	require_once __DIR__.'/lib/base.php';
30 30
 
31 31
 	if (isset($argv[1]) && ($argv[1] === '-h' || $argv[1] === '--help')) {
32 32
 		echo 'Description:
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	$appMode = $appConfig->getValueString('core', 'backgroundjobs_mode', 'ajax');
85 85
 	if ($appMode === 'none') {
86 86
 		if (OC::$CLI) {
87
-			echo 'Background Jobs are disabled!' . PHP_EOL;
87
+			echo 'Background Jobs are disabled!'.PHP_EOL;
88 88
 		} else {
89 89
 			OC_JSON::error(['data' => ['message' => 'Background jobs disabled!']]);
90 90
 		}
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
 
100 100
 		// the cron job must be executed with the right user
101 101
 		if (!function_exists('posix_getuid')) {
102
-			echo 'The posix extensions are required - see https://www.php.net/manual/en/book.posix.php' . PHP_EOL;
102
+			echo 'The posix extensions are required - see https://www.php.net/manual/en/book.posix.php'.PHP_EOL;
103 103
 			exit(1);
104 104
 		}
105 105
 
106 106
 		$user = posix_getuid();
107
-		$configUser = fileowner(OC::$configDir . 'config.php');
107
+		$configUser = fileowner(OC::$configDir.'config.php');
108 108
 		if ($user !== $configUser) {
109
-			echo 'Console has to be executed with the user that owns the file config/config.php' . PHP_EOL;
110
-			echo 'Current user id: ' . $user . PHP_EOL;
111
-			echo 'Owner id of config.php: ' . $configUser . PHP_EOL;
109
+			echo 'Console has to be executed with the user that owns the file config/config.php'.PHP_EOL;
110
+			echo 'Current user id: '.$user.PHP_EOL;
111
+			echo 'Owner id of config.php: '.$configUser.PHP_EOL;
112 112
 			exit(1);
113 113
 		}
114 114
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		$startHour = $config->getSystemValueInt('maintenance_window_start', 100);
128 128
 		if ($jobClasses === null && $startHour <= 23) {
129 129
 			$date = new \DateTime('now', new \DateTimeZone('UTC'));
130
-			$currentHour = (int)$date->format('G');
130
+			$currentHour = (int) $date->format('G');
131 131
 			$endHour = $startHour + 4;
132 132
 
133 133
 			if ($startHour <= 20) {
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
 				break;
161 161
 			}
162 162
 
163
-			$jobDetails = get_class($job) . ' (id: ' . $job->getId() . ', arguments: ' . json_encode($job->getArgument()) . ')';
164
-			$logger->debug('CLI cron call has selected job ' . $jobDetails, ['app' => 'cron']);
163
+			$jobDetails = get_class($job).' (id: '.$job->getId().', arguments: '.json_encode($job->getArgument()).')';
164
+			$logger->debug('CLI cron call has selected job '.$jobDetails, ['app' => 'cron']);
165 165
 
166 166
 			$timeBefore = time();
167 167
 			$memoryBefore = memory_get_usage();
168 168
 			$memoryPeakBefore = memory_get_peak_usage();
169 169
 
170 170
 			if ($verbose) {
171
-				echo 'Starting job ' . $jobDetails . PHP_EOL;
171
+				echo 'Starting job '.$jobDetails.PHP_EOL;
172 172
 			}
173 173
 
174 174
 			$job->start($jobList);
@@ -189,23 +189,23 @@  discard block
 block discarded – undo
189 189
 				};
190 190
 				$logger->log(
191 191
 					$logLevel,
192
-					'Background job ' . $jobDetails . ' ran for ' . $timeSpent . ' seconds',
192
+					'Background job '.$jobDetails.' ran for '.$timeSpent.' seconds',
193 193
 					['app' => 'cron']
194 194
 				);
195 195
 			}
196 196
 
197 197
 			if ($memoryAfter - $memoryBefore > 50_000_000) {
198
-				$message = 'Used memory grew by more than 50 MB when executing job ' . $jobDetails . ': ' . Util::humanFileSize($memoryAfter) . ' (before: ' . Util::humanFileSize($memoryBefore) . ')';
198
+				$message = 'Used memory grew by more than 50 MB when executing job '.$jobDetails.': '.Util::humanFileSize($memoryAfter).' (before: '.Util::humanFileSize($memoryBefore).')';
199 199
 				$logger->warning($message, ['app' => 'cron']);
200 200
 				if ($verbose) {
201
-					echo $message . PHP_EOL;
201
+					echo $message.PHP_EOL;
202 202
 				}
203 203
 			}
204 204
 			if ($memoryPeakAfter > 300_000_000 && $memoryPeakBefore <= 300_000_000) {
205
-				$message = 'Cron job used more than 300 MB of ram after executing job ' . $jobDetails . ': ' . Util::humanFileSize($memoryPeakAfter) . ' (before: ' . Util::humanFileSize($memoryPeakBefore) . ')';
205
+				$message = 'Cron job used more than 300 MB of ram after executing job '.$jobDetails.': '.Util::humanFileSize($memoryPeakAfter).' (before: '.Util::humanFileSize($memoryPeakBefore).')';
206 206
 				$logger->warning($message, ['app' => 'cron']);
207 207
 				if ($verbose) {
208
-					echo $message . PHP_EOL;
208
+					echo $message.PHP_EOL;
209 209
 				}
210 210
 			}
211 211
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 			$tempManager->clean();
215 215
 
216 216
 			if ($verbose) {
217
-				echo 'Job ' . $jobDetails . ' done in ' . ($timeAfter - $timeBefore) . ' seconds' . PHP_EOL;
217
+				echo 'Job '.$jobDetails.' done in '.($timeAfter - $timeBefore).' seconds'.PHP_EOL;
218 218
 			}
219 219
 
220 220
 			$jobList->setLastJob($job);
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			$jobList = Server::get(IJobList::class);
236 236
 			$job = $jobList->getNext();
237 237
 			if ($job != null) {
238
-				$logger->debug('WebCron call has selected job with ID ' . strval($job->getId()), ['app' => 'cron']);
238
+				$logger->debug('WebCron call has selected job with ID '.strval($job->getId()), ['app' => 'cron']);
239 239
 				$job->start($jobList);
240 240
 				$jobList->setLastJob($job);
241 241
 			}
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 		$ex->getMessage(),
252 252
 		['app' => 'cron', 'exception' => $ex]
253 253
 	);
254
-	echo $ex . PHP_EOL;
254
+	echo $ex.PHP_EOL;
255 255
 	exit(1);
256 256
 } catch (Error $ex) {
257 257
 	Server::get(LoggerInterface::class)->error(
258 258
 		$ex->getMessage(),
259 259
 		['app' => 'cron', 'exception' => $ex]
260 260
 	);
261
-	echo $ex . PHP_EOL;
261
+	echo $ex.PHP_EOL;
262 262
 	exit(1);
263 263
 }
Please login to merge, or discard this patch.
core/Command/Background/JobWorker.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			? null
69 69
 			: $this->parseStopAfter($stopAfterOptionValue);
70 70
 		if ($stopAfterSeconds !== null) {
71
-			$output->writeln('<info>Background job worker will stop after ' . $stopAfterSeconds . ' seconds</info>');
71
+			$output->writeln('<info>Background job worker will stop after '.$stopAfterSeconds.' seconds</info>');
72 72
 		}
73 73
 
74 74
 		$jobClasses = $input->getArgument('job-classes');
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			// at least one class is invalid
79 79
 			foreach ($jobClasses as $jobClass) {
80 80
 				if (!class_exists($jobClass)) {
81
-					$output->writeln('<error>Invalid job class: ' . $jobClass . '</error>');
81
+					$output->writeln('<error>Invalid job class: '.$jobClass.'</error>');
82 82
 					return 1;
83 83
 				}
84 84
 			}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 					if ($jobClasses === null) {
108 108
 						$output->writeln('No job is currently queued', OutputInterface::VERBOSITY_VERBOSE);
109 109
 					} else {
110
-						$output->writeln('No job of classes [' . implode(', ', $jobClasses) . '] is currently queued', OutputInterface::VERBOSITY_VERBOSE);
110
+						$output->writeln('No job of classes ['.implode(', ', $jobClasses).'] is currently queued', OutputInterface::VERBOSITY_VERBOSE);
111 111
 					}
112 112
 					$output->writeln('Exiting...', OutputInterface::VERBOSITY_VERBOSE);
113 113
 					break;
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 				continue;
120 120
 			}
121 121
 
122
-			$output->writeln('Running job ' . get_class($job) . ' with ID ' . $job->getId());
122
+			$output->writeln('Running job '.get_class($job).' with ID '.$job->getId());
123 123
 
124 124
 			if ($output->isVerbose()) {
125 125
 				$this->printJobInfo($job->getId(), $job, $output);
126 126
 			}
127 127
 
128 128
 			$job->start($this->jobList);
129
-			$output->writeln('Job ' . $job->getId() . ' has finished', OutputInterface::VERBOSITY_VERBOSE);
129
+			$output->writeln('Job '.$job->getId().' has finished', OutputInterface::VERBOSITY_VERBOSE);
130 130
 
131 131
 			// clean up after unclean jobs
132 132
 			$this->setupManager->tearDown();
@@ -158,16 +158,16 @@  discard block
 block discarded – undo
158 158
 
159 159
 	private function parseStopAfter(string $value): ?int {
160 160
 		if (is_numeric($value)) {
161
-			return (int)$value;
161
+			return (int) $value;
162 162
 		}
163 163
 		if (preg_match("/^(\d+)s$/i", $value, $matches)) {
164
-			return (int)$matches[0];
164
+			return (int) $matches[0];
165 165
 		}
166 166
 		if (preg_match("/^(\d+)m$/i", $value, $matches)) {
167
-			return 60 * ((int)$matches[0]);
167
+			return 60 * ((int) $matches[0]);
168 168
 		}
169 169
 		if (preg_match("/^(\d+)h$/i", $value, $matches)) {
170
-			return 60 * 60 * ((int)$matches[0]);
170
+			return 60 * 60 * ((int) $matches[0]);
171 171
 		}
172 172
 		return null;
173 173
 	}
Please login to merge, or discard this patch.
core/Command/Background/Job.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 	}
45 45
 
46 46
 	protected function execute(InputInterface $input, OutputInterface $output): int {
47
-		$jobId = (int)$input->getArgument('job-id');
47
+		$jobId = (int) $input->getArgument('job-id');
48 48
 
49 49
 		$job = $this->jobList->getById($jobId);
50 50
 		if ($job === null) {
51
-			$output->writeln('<error>Job with ID ' . $jobId . ' could not be found in the database</error>');
51
+			$output->writeln('<error>Job with ID '.$jobId.' could not be found in the database</error>');
52 52
 			return 1;
53 53
 		}
54 54
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
 		$job = $this->jobList->getById($jobId);
68 68
 		if ($job === null) {
69
-			$output->writeln('<error>Something went wrong when trying to retrieve Job with ID ' . $jobId . ' from database</error>');
69
+			$output->writeln('<error>Something went wrong when trying to retrieve Job with ID '.$jobId.' from database</error>');
70 70
 			return 1;
71 71
 		}
72 72
 		$job->start($this->jobList);
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 		$row = $this->jobList->getDetailsById($jobId);
92 92
 
93 93
 		$lastRun = new \DateTime();
94
-		$lastRun->setTimestamp((int)$row['last_run']);
94
+		$lastRun->setTimestamp((int) $row['last_run']);
95 95
 		$lastChecked = new \DateTime();
96
-		$lastChecked->setTimestamp((int)$row['last_checked']);
96
+		$lastChecked->setTimestamp((int) $row['last_checked']);
97 97
 		$reservedAt = new \DateTime();
98
-		$reservedAt->setTimestamp((int)$row['reserved_at']);
98
+		$reservedAt->setTimestamp((int) $row['reserved_at']);
99 99
 
100
-		$output->writeln('Job class:            ' . get_class($job));
101
-		$output->writeln('Arguments:            ' . json_encode($job->getArgument()));
100
+		$output->writeln('Job class:            '.get_class($job));
101
+		$output->writeln('Arguments:            '.json_encode($job->getArgument()));
102 102
 
103 103
 		$isTimedJob = $job instanceof TimedJob;
104 104
 		if ($isTimedJob) {
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
 		}
111 111
 
112 112
 		$output->writeln('');
113
-		$output->writeln('Last checked:         ' . $lastChecked->format(\DateTimeInterface::ATOM));
114
-		if ((int)$row['reserved_at'] === 0) {
113
+		$output->writeln('Last checked:         '.$lastChecked->format(\DateTimeInterface::ATOM));
114
+		if ((int) $row['reserved_at'] === 0) {
115 115
 			$output->writeln('Reserved at:          -');
116 116
 		} else {
117
-			$output->writeln('Reserved at:          <comment>' . $reservedAt->format(\DateTimeInterface::ATOM) . '</comment>');
117
+			$output->writeln('Reserved at:          <comment>'.$reservedAt->format(\DateTimeInterface::ATOM).'</comment>');
118 118
 		}
119
-		$output->writeln('Last executed:        ' . $lastRun->format(\DateTimeInterface::ATOM));
120
-		$output->writeln('Last duration:        ' . $row['execution_duration']);
119
+		$output->writeln('Last executed:        '.$lastRun->format(\DateTimeInterface::ATOM));
120
+		$output->writeln('Last duration:        '.$row['execution_duration']);
121 121
 
122 122
 		if ($isTimedJob) {
123 123
 			$reflection = new \ReflectionClass($job);
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 			$nextRun->setTimestamp($row['last_run'] + $interval);
130 130
 
131 131
 			if ($nextRun > new \DateTime()) {
132
-				$output->writeln('Next execution:       <comment>' . $nextRun->format(\DateTimeInterface::ATOM) . '</comment>');
132
+				$output->writeln('Next execution:       <comment>'.$nextRun->format(\DateTimeInterface::ATOM).'</comment>');
133 133
 			} else {
134
-				$output->writeln('Next execution:       <info>' . $nextRun->format(\DateTimeInterface::ATOM) . '</info>');
134
+				$output->writeln('Next execution:       <info>'.$nextRun->format(\DateTimeInterface::ATOM).'</info>');
135 135
 			}
136 136
 		}
137 137
 	}
Please login to merge, or discard this patch.