Completed
Pull Request — master (#643)
by Stig
07:47
created
code/extensions/DeploynautFileExtension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 		$file = $this->owner;
12 12
 		$archive = DNDataArchive::get()->filter('ArchiveFileID', $file->ID)->First();
13 13
 
14
-		if($archive) {
14
+		if ($archive) {
15 15
 			return $archive->canDownload($member);
16 16
 		}
17 17
 
Please login to merge, or discard this patch.
code/queuereport/ResqueReport.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 	protected function getQueues() {
54 54
 		$queues = Resque::queues();
55 55
 		$queueList = new ArrayList();
56
-		foreach($queues as $idx => $queue) {
56
+		foreach ($queues as $idx => $queue) {
57 57
 			$queueList->push(new ResqueQueue(array(
58 58
 				'ID' => ($idx + 1),
59 59
 				'Name' => $queue,
Please login to merge, or discard this patch.
code/queuereport/ResqueJob.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 	 * @return mixed
61 61
 	 */
62 62
 	public function __get($property) {
63
-		if(isset($this->record[$property])) {
63
+		if (isset($this->record[$property])) {
64 64
 			return $this->record[$property];
65 65
 		}
66 66
 		return null;
Please login to merge, or discard this patch.
code/queuereport/ResqueQueue.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 	protected function getJobs() {
50 50
 		$jobs = new ArrayList();
51 51
 
52
-		$resqueJobs = Resque::redis()->lrange('queue:' . $this->Name, 0, -1);
53
-		if(!$resqueJobs) {
52
+		$resqueJobs = Resque::redis()->lrange('queue:'.$this->Name, 0, -1);
53
+		if (!$resqueJobs) {
54 54
 			$jobs->push(new ResqueJob(array(
55 55
 				'Name' => 'null',
56 56
 				'Value' => 'null',
57 57
 			)));
58 58
 			return $jobs;
59 59
 		}
60
-		foreach($resqueJobs as $idx => $job) {
60
+		foreach ($resqueJobs as $idx => $job) {
61 61
 			$stdClass = json_decode($job);
62
-			if($stdClass->class === 'CapistranoDeploy' || $stdClass->class === 'DeployJob') {
62
+			if ($stdClass->class === 'CapistranoDeploy' || $stdClass->class === 'DeployJob') {
63 63
 				$value = $stdClass->args[0]->projectName
64
-					. ':' . $stdClass->args[0]->environment
65
-					. ' - ' . $stdClass->args[0]->sha;
64
+					. ':'.$stdClass->args[0]->environment
65
+					. ' - '.$stdClass->args[0]->sha;
66 66
 				$jobs->push(new ResqueJob(array(
67 67
 					'Name' => $stdClass->class,
68 68
 					'Value' => $value,
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @return mixed
112 112
 	 */
113 113
 	public function __get($property) {
114
-		if(isset($this->record[$property])) {
114
+		if (isset($this->record[$property])) {
115 115
 			return $this->record[$property];
116 116
 		}
117 117
 		return null;
Please login to merge, or discard this patch.
code/AbortableProcess.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 class AbortableProcess extends \Symfony\Component\Process\Process {
16 16
 	public function run($callback = null) {
17 17
 		$this->start($callback);
18
-		while($this->isRunning()) {
18
+		while ($this->isRunning()) {
19 19
 			$this->checkTimeout();
20 20
 			sleep(1);
21 21
 		}
Please login to merge, or discard this patch.
code/model/jobs/DNDeployment.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 
103 103
 	public function LogLink() {
104
-		return $this->Link() . '/log';
104
+		return $this->Link().'/log';
105 105
 	}
106 106
 
107 107
 	public function canView($member = null) {
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		if (!$interface) {
177 177
 			return null;
178 178
 		}
179
-		return $interface->CommitURL . '/' . $this->SHA;
179
+		return $interface->CommitURL.'/'.$this->SHA;
180 180
 	}
181 181
 
182 182
 	/**
Please login to merge, or discard this patch.
code/model/DNDataArchive.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 			return false;
228 228
 		}
229 229
 
230
-		$key = $memberID . '-' . $this->EnvironmentID;
230
+		$key = $memberID.'-'.$this->EnvironmentID;
231 231
 		if (!isset(self::$_cache_can_restore[$key])) {
232 232
 			self::$_cache_can_restore[$key] = $this->Environment()->canUploadArchive($member);
233 233
 		}
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 			return false;
249 249
 		}
250 250
 
251
-		$key = $memberID . '-' . $this->EnvironmentID;
251
+		$key = $memberID.'-'.$this->EnvironmentID;
252 252
 		if (!isset(self::$_cache_can_download[$key])) {
253 253
 			self::$_cache_can_download[$key] = $this->Environment()->canDownloadArchive($member);
254 254
 		}
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	public function validTargetEnvironments() {
314 314
 		$archive = $this;
315 315
 		$envs = $this->Environment()->Project()->DNEnvironmentList()
316
-			->filterByCallback(function ($item) use ($archive) {
316
+			->filterByCallback(function($item) use ($archive) {
317 317
 				return $archive->EnvironmentID != $item->ID && $archive->canMoveTo($item);
318 318
 			});
319 319
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 			mkdir($workingDir, 0700, true);
408 408
 		}
409 409
 
410
-		$cleanupFn = function () use ($workingDir) {
410
+		$cleanupFn = function() use ($workingDir) {
411 411
 			$process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir)));
412 412
 			$process->setTimeout(120);
413 413
 			$process->run();
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		}
429 429
 
430 430
 		// Extract database.sql.gz to <workingdir>/database.sql
431
-		if (file_exists($workingDir . DIRECTORY_SEPARATOR . 'database.sql.gz')) {
431
+		if (file_exists($workingDir.DIRECTORY_SEPARATOR.'database.sql.gz')) {
432 432
 			$process = new AbortableProcess('gunzip database.sql.gz', $workingDir);
433 433
 			$process->setTimeout(3600);
434 434
 			$process->run();
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 		}
440 440
 
441 441
 		// Extract assets.tar.gz to <workingdir>/assets/
442
-		if (file_exists($workingDir . DIRECTORY_SEPARATOR . 'assets.tar.gz')) {
442
+		if (file_exists($workingDir.DIRECTORY_SEPARATOR.'assets.tar.gz')) {
443 443
 			$process = new AbortableProcess('tar xzf assets.tar.gz', $workingDir);
444 444
 			$process->setTimeout(3600);
445 445
 			$process->run();
Please login to merge, or discard this patch.
code/jobs/DeployJob.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 	public function alarmHandler() {
19 19
 		$sigFile = $this->args['sigFile'];
20 20
 		if (file_exists($sigFile) && is_readable($sigFile) && is_writable($sigFile)) {
21
-			$signal = (int)file_get_contents($sigFile);
22
-			if (is_int($signal) && in_array((int)$signal, [
21
+			$signal = (int) file_get_contents($sigFile);
22
+			if (is_int($signal) && in_array((int) $signal, [
23 23
 				// The following signals are trapped by both Resque and Rainforest.
24 24
 				SIGTERM,
25 25
 				SIGINT,
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 				SIGCONT
31 31
 			])) {
32 32
 				echo sprintf(
33
-					'[-] Signal "%s" received, delivering to own process group, PID "%s".' . PHP_EOL,
33
+					'[-] Signal "%s" received, delivering to own process group, PID "%s".'.PHP_EOL,
34 34
 					$signal,
35 35
 					getmypid()
36 36
 				);
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 
41 41
 				// Dispatch to own process group.
42 42
 				$pgid = posix_getpgid(getmypid());
43
-				if ($pgid<=0) {
43
+				if ($pgid <= 0) {
44 44
 					echo sprintf(
45
-						'[-] Unable to send signal to invalid PGID "%s".' . PHP_EOL,
45
+						'[-] Unable to send signal to invalid PGID "%s".'.PHP_EOL,
46 46
 						$pgid
47 47
 					);
48 48
 				} else {
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 		// to this job as a whole (including any subprocesses such as spawned by Symfony).
61 61
 		posix_setsid();
62 62
 
63
-		if(function_exists('pcntl_alarm') && function_exists('pcntl_signal')) {
63
+		if (function_exists('pcntl_alarm') && function_exists('pcntl_signal')) {
64 64
 			if (!empty($this->args['sigFile'])) {
65
-				echo sprintf('[-] Signal file requested, polling "%s".' . PHP_EOL, $this->args['sigFile']);
65
+				echo sprintf('[-] Signal file requested, polling "%s".'.PHP_EOL, $this->args['sigFile']);
66 66
 				declare(ticks = 1);
67 67
 				pcntl_signal(SIGALRM, [$this, 'alarmHandler']);
68 68
 				pcntl_alarm(1);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	public function perform() {
77
-		echo "[-] DeployJob starting" . PHP_EOL;
77
+		echo "[-] DeployJob starting".PHP_EOL;
78 78
 		$log = new DeploynautLogFile($this->args['logfile']);
79 79
 
80 80
 		$deployment = DNDeployment::get()->byID($this->args['deploymentID']);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		// deploy onto a clean environment will not be performing any backup regardless of
93 93
 		// whether the predeploy_backup option was passed or not.
94 94
 		// Sometimes predeploy_backup comes through as string false from the frontend.
95
-		if(
95
+		if (
96 96
 			!empty($this->args['predeploy_backup'])
97 97
 			&& $this->args['predeploy_backup'] !== 'false'
98 98
 			&& !empty($currentBuild)
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 			// Disallow concurrent deployments (don't rely on queuing implementation to restrict this)
115 115
 			// Only consider deployments started in the last 30 minutes (older jobs probably got stuck)
116 116
 			$runningDeployments = $environment->runningDeployments()->exclude('ID', $this->args['deploymentID']);
117
-			if($runningDeployments->count()) {
117
+			if ($runningDeployments->count()) {
118 118
 				$runningDeployment = $runningDeployments->first();
119 119
 				$message = sprintf(
120 120
 					'Error: another deployment is in progress (started at %s by %s)',
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 				// all options from the DeploymentStrategy merged in, including sha.
135 135
 				$this->args
136 136
 			);
137
-		} catch(Exception $e) {
137
+		} catch (Exception $e) {
138 138
 			// DeploynautJob will automatically trigger onFailure.
139
-			echo "[-] DeployJob failed" . PHP_EOL;
139
+			echo "[-] DeployJob failed".PHP_EOL;
140 140
 			throw $e;
141 141
 		}
142 142
 
143 143
 		$this->updateStatus(DNDeployment::TR_COMPLETE);
144
-		echo "[-] DeployJob finished" . PHP_EOL;
144
+		echo "[-] DeployJob finished".PHP_EOL;
145 145
 	}
146 146
 
147 147
 	public function onFailure(Exception $exception) {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			DB::connect($databaseConfig);
161 161
 			$backupDataTransfer->Status = 'Finished';
162 162
 			$backupDataTransfer->write();
163
-		} catch(Exception $e) {
163
+		} catch (Exception $e) {
164 164
 			global $databaseConfig;
165 165
 			DB::connect($databaseConfig);
166 166
 			$backupDataTransfer->Status = 'Failed';
Please login to merge, or discard this patch.
code/control/DeploynautLogFile.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @return string
46 46
 	 */
47 47
 	public function getRawFilePath() {
48
-		return $this->basePath . '/' . $this->logFile;
48
+		return $this->basePath.'/'.$this->logFile;
49 49
 	}
50 50
 
51 51
 	/**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @return string
54 54
 	 */
55 55
 	public function getSanitisedLogFilePath() {
56
-		return $this->basePath . '/' . strtolower(FileNameFilter::create()->filter($this->logFile));
56
+		return $this->basePath.'/'.strtolower(FileNameFilter::create()->filter($this->logFile));
57 57
 	}
58 58
 
59 59
 	/**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		// Make sure we write into the old path for existing logs. New logs use the sanitised file path instead.
84 84
 		$path = file_exists($this->getRawFilePath()) ? $this->getRawFilePath() : $this->getSanitisedLogFilePath();
85 85
 
86
-		error_log('[' . date('Y-m-d H:i:s') . '] ' . $message . PHP_EOL, 3, $path);
86
+		error_log('['.date('Y-m-d H:i:s').'] '.$message.PHP_EOL, 3, $path);
87 87
 		@chmod($path, 0666);
88 88
 	}
89 89
 
Please login to merge, or discard this patch.