Completed
Pull Request — master (#681)
by Sean
06:15
created
code/extensions/DeploynautSecurityExtension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 		// the 'ping' action is called via AJAX from the /admin and will cause
7 7
 		// the admin section to 'grow' over time. We only need the css and js
8 8
 		// for login, reset, logout and so on.
9
-		if(!$this->owner->getRequest()->isAjax()) {
9
+		if (!$this->owner->getRequest()->isAjax()) {
10 10
 			DNRoot::include_requirements();
11 11
 		}
12 12
 	}
Please login to merge, or discard this patch.
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/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.
code/control/DNRoot.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		Requirements::javascript('deploynaut/javascript/material.js');
179 179
 
180 180
 		// Load the buildable dependencies only if not loaded centrally.
181
-		if (!is_dir(BASE_PATH . DIRECTORY_SEPARATOR . 'static')) {
181
+		if (!is_dir(BASE_PATH.DIRECTORY_SEPARATOR.'static')) {
182 182
 			if (\Director::isDev()) {
183 183
 				\Requirements::javascript('deploynaut/static/bundle-debug.js');
184 184
 			} else {
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 		}
243 243
 
244 244
 		// Block framework jquery
245
-		Requirements::block(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js');
245
+		Requirements::block(FRAMEWORK_DIR.'/thirdparty/jquery/jquery.js');
246 246
 
247 247
 		self::include_requirements();
248 248
 	}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @return \SS_HTTPResponse
262 262
 	 */
263 263
 	public function index(SS_HTTPRequest $request) {
264
-		return $this->redirect($this->Link() . 'projects/');
264
+		return $this->redirect($this->Link().'projects/');
265 265
 	}
266 266
 
267 267
 	/**
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 		// Framing an environment as a "group of people with download access"
390 390
 		// makes more sense to the user here, while still allowing us to enforce
391 391
 		// environment specific restrictions on downloading the file later on.
392
-		$envs = $project->DNEnvironmentList()->filterByCallback(function ($item) {
392
+		$envs = $project->DNEnvironmentList()->filterByCallback(function($item) {
393 393
 			return $item->canUploadArchive();
394 394
 		});
395 395
 		$envsMap = [];
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 		$form->disableSecurityToken();
422 422
 		$form->addExtraClass('fields-wide');
423 423
 		// Tweak the action so it plays well with our fake URL structure.
424
-		$form->setFormAction($project->Link() . '/UploadSnapshotForm');
424
+		$form->setFormAction($project->Link().'/UploadSnapshotForm');
425 425
 
426 426
 		return $form;
427 427
 	}
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 		}
443 443
 
444 444
 		$validEnvs = $project->DNEnvironmentList()
445
-			->filterByCallback(function ($item) {
445
+			->filterByCallback(function($item) {
446 446
 				return $item->canUploadArchive();
447 447
 			});
448 448
 
@@ -471,9 +471,9 @@  discard block
 block discarded – undo
471 471
 		$dataArchive->DataTransfers()->add($dataTransfer);
472 472
 		$form->saveInto($dataArchive);
473 473
 		$dataArchive->write();
474
-		$workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID;
474
+		$workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID;
475 475
 
476
-		$cleanupFn = function () use ($workingDir, $dataTransfer, $dataArchive) {
476
+		$cleanupFn = function() use ($workingDir, $dataTransfer, $dataArchive) {
477 477
 			$process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir)));
478 478
 			$process->setTimeout(120);
479 479
 			$process->run();
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 		// Framing an environment as a "group of people with download access"
548 548
 		// makes more sense to the user here, while still allowing us to enforce
549 549
 		// environment specific restrictions on downloading the file later on.
550
-		$envs = $project->DNEnvironmentList()->filterByCallback(function ($item) {
550
+		$envs = $project->DNEnvironmentList()->filterByCallback(function($item) {
551 551
 			return $item->canUploadArchive();
552 552
 		});
553 553
 		$envsMap = [];
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 		$form->disableSecurityToken();
574 574
 		$form->addExtraClass('fields-wide');
575 575
 		// Tweak the action so it plays well with our fake URL structure.
576
-		$form->setFormAction($project->Link() . '/PostSnapshotForm');
576
+		$form->setFormAction($project->Link().'/PostSnapshotForm');
577 577
 
578 578
 		return $form;
579 579
 	}
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 			return $this->project404Response();
593 593
 		}
594 594
 
595
-		$validEnvs = $project->DNEnvironmentList()->filterByCallback(function ($item) {
595
+		$validEnvs = $project->DNEnvironmentList()->filterByCallback(function($item) {
596 596
 			return $item->canUploadArchive();
597 597
 		});
598 598
 
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 		$branchName = $request->getVar('name');
713 713
 		$branch = $project->DNBranchList()->byName($branchName);
714 714
 		if (!$branch) {
715
-			return new SS_HTTPResponse("Branch '" . Convert::raw2xml($branchName) . "' not found.", 404);
715
+			return new SS_HTTPResponse("Branch '".Convert::raw2xml($branchName)."' not found.", 404);
716 716
 		}
717 717
 
718 718
 		return $this->render([
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 		);
850 850
 
851 851
 		// Tweak the action so it plays well with our fake URL structure.
852
-		$form->setFormAction($project->Link() . '/CreateEnvironmentForm');
852
+		$form->setFormAction($project->Link().'/CreateEnvironmentForm');
853 853
 
854 854
 		return $form;
855 855
 	}
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 		$job->write();
883 883
 		$job->start();
884 884
 
885
-		return $this->redirect($project->Link('createenv') . '/' . $job->ID);
885
+		return $this->redirect($project->Link('createenv').'/'.$job->ID);
886 886
 	}
887 887
 
888 888
 	/**
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 			return $body;
1081 1081
 		}
1082 1082
 
1083
-		$form->setFormAction($this->getRequest()->getURL() . '/DeployForm');
1083
+		$form->setFormAction($this->getRequest()->getURL().'/DeployForm');
1084 1084
 		return $form;
1085 1085
 	}
1086 1086
 
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
 		$deployment->getMachine()->apply(DNDeployment::TR_QUEUE);
1347 1347
 
1348 1348
 		return json_encode([
1349
-			'url' => Director::absoluteBaseURL() . $deployment->Link()
1349
+			'url' => Director::absoluteBaseURL().$deployment->Link()
1350 1350
 		], JSON_PRETTY_PRINT);
1351 1351
 	}
1352 1352
 
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 	 */
1470 1470
 	public function getDataTransferForm(SS_HTTPRequest $request = null) {
1471 1471
 		// Performs canView permission check by limiting visible projects
1472
-		$envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function ($item) {
1472
+		$envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function($item) {
1473 1473
 			return $item->canBackup();
1474 1474
 		});
1475 1475
 
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
 					->addExtraClass('btn')
1492 1492
 			)
1493 1493
 		);
1494
-		$form->setFormAction($this->getRequest()->getURL() . '/DataTransferForm');
1494
+		$form->setFormAction($this->getRequest()->getURL().'/DataTransferForm');
1495 1495
 
1496 1496
 		return $form;
1497 1497
 	}
@@ -1517,12 +1517,12 @@  discard block
 block discarded – undo
1517 1517
 		// Validate direction.
1518 1518
 		if ($data['Direction'] == 'get') {
1519 1519
 			$validEnvs = $this->getCurrentProject()->DNEnvironmentList()
1520
-				->filterByCallback(function ($item) {
1520
+				->filterByCallback(function($item) {
1521 1521
 					return $item->canBackup();
1522 1522
 				});
1523 1523
 		} else if ($data['Direction'] == 'push') {
1524 1524
 			$validEnvs = $this->getCurrentProject()->DNEnvironmentList()
1525
-				->filterByCallback(function ($item) {
1525
+				->filterByCallback(function($item) {
1526 1526
 					return $item->canRestore();
1527 1527
 				});
1528 1528
 		} else {
@@ -1653,7 +1653,7 @@  discard block
 block discarded – undo
1653 1653
 
1654 1654
 		// Performs canView permission check by limiting visible projects
1655 1655
 		$project = $this->getCurrentProject();
1656
-		$envs = $project->DNEnvironmentList()->filterByCallback(function ($item) {
1656
+		$envs = $project->DNEnvironmentList()->filterByCallback(function($item) {
1657 1657
 			return $item->canRestore();
1658 1658
 		});
1659 1659
 
@@ -1692,7 +1692,7 @@  discard block
 block discarded – undo
1692 1692
 					->addExtraClass('btn')
1693 1693
 			)
1694 1694
 		);
1695
-		$form->setFormAction($project->Link() . '/DataTransferRestoreForm');
1695
+		$form->setFormAction($project->Link().'/DataTransferRestoreForm');
1696 1696
 
1697 1697
 		return $form;
1698 1698
 	}
@@ -1790,7 +1790,7 @@  discard block
 block discarded – undo
1790 1790
 					->addExtraClass('btn')
1791 1791
 			)
1792 1792
 		);
1793
-		$form->setFormAction($project->Link() . '/DeleteForm');
1793
+		$form->setFormAction($project->Link().'/DeleteForm');
1794 1794
 
1795 1795
 		return $form;
1796 1796
 	}
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 					->addExtraClass('btn')
1897 1897
 			)
1898 1898
 		);
1899
-		$form->setFormAction($this->getCurrentProject()->Link() . '/MoveForm');
1899
+		$form->setFormAction($this->getCurrentProject()->Link().'/MoveForm');
1900 1900
 
1901 1901
 		return $form;
1902 1902
 	}
@@ -2157,7 +2157,7 @@  discard block
 block discarded – undo
2157 2157
 		$transfers = DNDataTransfer::get()
2158 2158
 			->filter('EnvironmentID', $environments)
2159 2159
 			->filterByCallback(
2160
-				function ($record) {
2160
+				function($record) {
2161 2161
 					return
2162 2162
 						$record->Environment()->canRestore() || // Ensure member can perform an action on the transfers env
2163 2163
 						$record->Environment()->canBackup() ||
@@ -2282,7 +2282,7 @@  discard block
 block discarded – undo
2282 2282
 	 */
2283 2283
 	protected function project404Response() {
2284 2284
 		return new SS_HTTPResponse(
2285
-			"Project '" . Convert::raw2xml($this->getRequest()->param('Project')) . "' not found.",
2285
+			"Project '".Convert::raw2xml($this->getRequest()->param('Project'))."' not found.",
2286 2286
 			404
2287 2287
 		);
2288 2288
 	}
@@ -2292,7 +2292,7 @@  discard block
 block discarded – undo
2292 2292
 	 */
2293 2293
 	protected function environment404Response() {
2294 2294
 		$envName = Convert::raw2xml($this->getRequest()->param('Environment'));
2295
-		return new SS_HTTPResponse("Environment '" . $envName . "' not found.", 404);
2295
+		return new SS_HTTPResponse("Environment '".$envName."' not found.", 404);
2296 2296
 	}
2297 2297
 
2298 2298
 	/**
Please login to merge, or discard this patch.