Completed
Pull Request — master (#575)
by Mateusz
03:31
created
code/tasks/SyncProjectsAndEnvironments.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
 
20 20
 		if($dryRun) {
21 21
 			echo "Running in dry run mode, no changes commited, ";
22
-			echo "the output shows a prediction on what will happen." . PHP_EOL;
23
-			echo "To skip dryrun, run the task like this:" . PHP_EOL;
24
-			echo "./framework/sake dev/tasks/SyncProjectsAndEnvironments dryrun=0" . PHP_EOL . PHP_EOL;
22
+			echo "the output shows a prediction on what will happen.".PHP_EOL;
23
+			echo "To skip dryrun, run the task like this:".PHP_EOL;
24
+			echo "./framework/sake dev/tasks/SyncProjectsAndEnvironments dryrun=0".PHP_EOL.PHP_EOL;
25 25
 			sleep(3);
26 26
 		}
27 27
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		}
68 68
 
69 69
 		foreach($removeList as $remove) {
70
-			$this->message('Removing "' . basename($remove->Name) . '" from db');
70
+			$this->message('Removing "'.basename($remove->Name).'" from db');
71 71
 			if(!$dryRun) {
72 72
 				$removeList->remove($remove);
73 73
 			}
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		}
89 89
 
90 90
 		foreach($removeList as $remove) {
91
-			$this->message($remove->Name . ' ' . $remove->Path);
91
+			$this->message($remove->Name.' '.$remove->Path);
92 92
 			if(!$dryrun) {
93 93
 				$removeList->remove($remove);
94 94
 			}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 				continue;
121 121
 			}
122 122
 
123
-			$this->message('Adding "' . basename($path) . '" to db');
123
+			$this->message('Adding "'.basename($path).'" to db');
124 124
 			if(!$dryRun) {
125 125
 				$environment = DNEnvironment::create_from_path($path);
126 126
 				$environment->ProjectID = $project->ID;
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	protected function message($text) {
153 153
 		if(PHP_SAPI !== 'cli') {
154
-			$text = '<p>' . $text . '</p>' . PHP_EOL;
154
+			$text = '<p>'.$text.'</p>'.PHP_EOL;
155 155
 		}
156
-		echo ' - ' . $text . PHP_EOL;
156
+		echo ' - '.$text.PHP_EOL;
157 157
 	}
158 158
 
159 159
 	/**
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	protected function echoHeader($text) {
163 163
 		if(PHP_SAPI !== 'cli') {
164
-			echo '<h2>' . $text . '</h2>' . PHP_EOL;
164
+			echo '<h2>'.$text.'</h2>'.PHP_EOL;
165 165
 		} else {
166
-			echo '# ' . $text . PHP_EOL;
166
+			echo '# '.$text.PHP_EOL;
167 167
 		}
168 168
 	}
169 169
 }
Please login to merge, or discard this patch.
code/api/nouns/APIProject.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,9 +87,9 @@
 block discarded – undo
87 87
 		$fetch->write();
88 88
 		$fetch->start();
89 89
 
90
-		$location = Director::absoluteBaseURL() . $this->Link() . '/fetch/' . $fetch->ID;
90
+		$location = Director::absoluteBaseURL().$this->Link().'/fetch/'.$fetch->ID;
91 91
 		$output = array(
92
-			'message' => 'Fetch queued as job ' . $fetch->ResqueToken,
92
+			'message' => 'Fetch queued as job '.$fetch->ResqueToken,
93 93
 			'href' => $location,
94 94
 		);
95 95
 
Please login to merge, or discard this patch.
code/api/nouns/APIEnvironment.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 		$ping->write();
113 113
 		$ping->start();
114 114
 
115
-		$location = Director::absoluteBaseURL() . $this->Link() . '/ping/' . $ping->ID;
115
+		$location = Director::absoluteBaseURL().$this->Link().'/ping/'.$ping->ID;
116 116
 		$output = array(
117
-			'message' => 'Ping queued as job ' . $ping->ResqueToken,
117
+			'message' => 'Ping queued as job '.$ping->ResqueToken,
118 118
 			'href' => $location,
119 119
 		);
120 120
 
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 		));
165 165
 		$deploy = $strategy->createDeployment();
166 166
 		$deploy->start();
167
-		$location = Director::absoluteBaseURL() . $this->Link() . '/deploy/' . $deploy->ID;
167
+		$location = Director::absoluteBaseURL().$this->Link().'/deploy/'.$deploy->ID;
168 168
 		$output = array(
169
-			'message' => 'Deploy queued as job ' . $deploy->ResqueToken,
169
+			'message' => 'Deploy queued as job '.$deploy->ResqueToken,
170 170
 			'href' => $location,
171 171
 		);
172 172
 		$response = $this->getAPIResponse($output);
Please login to merge, or discard this patch.
code/api/DeploynautAPI.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function project404Response() {
107 107
 		$projectName = Convert::raw2xml($this->getRequest()->latestParam('Project'));
108
-		return new SS_HTTPResponse('Project "' . $projectName . '" not found.', 404);
108
+		return new SS_HTTPResponse('Project "'.$projectName.'" not found.', 404);
109 109
 	}
110 110
 
111 111
 	/**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	protected function environment404Response() {
115 115
 		$envName = Convert::raw2xml($this->getRequest()->latestParam('Environment'));
116
-		return new SS_HTTPResponse('Environment "' . $envName . '" not found.', 404);
116
+		return new SS_HTTPResponse('Environment "'.$envName.'" not found.', 404);
117 117
 	}
118 118
 
119 119
 	/**
Please login to merge, or discard this patch.
code/jobs/PingJob.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 	 * Do the actual job by calling the appropiate backend
32 32
 	 */
33 33
 	public function perform() {
34
-		echo "[-] PingJob starting" . PHP_EOL;
34
+		echo "[-] PingJob starting".PHP_EOL;
35 35
 		$log = new DeploynautLogFile($this->args['logfile']);
36 36
 
37 37
 		$ping = DNPing::get()->byID($this->args['pingID']);
Please login to merge, or discard this patch.
code/jobs/CreateEnvJob.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 */
21 21
 	public function perform() {
22
-		echo "[-] CreateEnvJob starting" . PHP_EOL;
22
+		echo "[-] CreateEnvJob starting".PHP_EOL;
23 23
 		// This is a bit icky, but there is no easy way of capturing a failed deploy by using the PHP Resque
24 24
 		try {
25 25
 			$envCreate = DNCreateEnvironment::get()->byId($this->args['createID']);
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 			$envCreate->createEnvironment();
32 32
 
33 33
 		} catch(Exception $e) {
34
-			echo "[-] CreateEnvJob failed" . PHP_EOL;
34
+			echo "[-] CreateEnvJob failed".PHP_EOL;
35 35
 			throw $e;
36 36
 		}
37 37
 		$this->updateStatus('Finished');
38
-		echo "[-] CreateEnvJob finished" . PHP_EOL;
38
+		echo "[-] CreateEnvJob finished".PHP_EOL;
39 39
 	}
40 40
 
41 41
 	/**
Please login to merge, or discard this patch.
code/jobs/DataTransferJob.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	}
21 21
 
22 22
 	public function perform() {
23
-		echo "[-] DataTransferJob starting" . PHP_EOL;
23
+		echo "[-] DataTransferJob starting".PHP_EOL;
24 24
 		$log = new DeploynautLogFile($this->args['logfile']);
25 25
 		$dataTransfer = DNDataTransfer::get()->byID($this->args['dataTransferID']);
26 26
 		$environment = $dataTransfer->Environment();
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 		} catch(RuntimeException $exc) {
84 84
 			$log->write($exc->getMessage());
85 85
 
86
-			echo "[-] DataTransferJob failed" . PHP_EOL;
86
+			echo "[-] DataTransferJob failed".PHP_EOL;
87 87
 			throw $exc;
88 88
 		}
89 89
 
90 90
 		$this->updateStatus('Finished');
91
-		echo "[-] DataTransferJob finished" . PHP_EOL;
91
+		echo "[-] DataTransferJob finished".PHP_EOL;
92 92
 	}
93 93
 
94 94
 	/**
Please login to merge, or discard this patch.
code/model/jobs/DNDeployment.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -205,12 +205,16 @@
 block discarded – undo
205 205
 	 */
206 206
 	public function getFullDeployMessages() {
207 207
 		$strategy = $this->getDeploymentStrategy();
208
-		if ($strategy->getActionCode()!=='full') return null;
208
+		if ($strategy->getActionCode()!=='full') {
209
+			return null;
210
+		}
209 211
 
210 212
 		$changes = $strategy->getChangesModificationNeeded();
211 213
 		$messages = [];
212 214
 		foreach ($changes as $change => $details) {
213
-			if ($change==='Code version') continue;
215
+			if ($change==='Code version') {
216
+				continue;
217
+			}
214 218
 
215 219
 			$messages[] = [
216 220
 				'Flag' => sprintf(
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	}
74 74
 
75 75
 	public function LogLink() {
76
-		return $this->Link() . '/log';
76
+		return $this->Link().'/log';
77 77
 	}
78 78
 
79 79
 	public function canView($member = null) {
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	public function getFullDeployMessages() {
209 209
 		$strategy = $this->getDeploymentStrategy();
210
-		if ($strategy->getActionCode()!=='full') return null;
210
+		if($strategy->getActionCode() !== 'full') return null;
211 211
 
212 212
 		$changes = $strategy->getChangesModificationNeeded();
213 213
 		$messages = [];
214
-		foreach ($changes as $change => $details) {
215
-			if ($change==='Code version') continue;
214
+		foreach($changes as $change => $details) {
215
+			if($change === 'Code version') continue;
216 216
 
217 217
 			$messages[] = [
218 218
 				'Flag' => sprintf(
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			];
224 224
 		}
225 225
 
226
-		if (empty($messages)) {
226
+		if(empty($messages)) {
227 227
 			$messages[] = [
228 228
 				'Flag' => '',
229 229
 				'Text' => '<i>Environment changes have been made.</i>'
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 
273 273
 			// if there is a compare URL, and a description or a change (something actually changed)
274 274
 			// then show the URL. Otherwise don't show anything, as there is no comparison to be made.
275
-			if ($changed || $description) {
275
+			if($changed || $description) {
276 276
 				$compareUrl = isset($change['compareUrl']) ? $change['compareUrl'] : '';
277 277
 			}
278 278
 
@@ -353,6 +353,6 @@  discard block
 block discarded – undo
353 353
 	}
354 354
 
355 355
 	public function isAborting() {
356
-		return $this->Status=='Aborting';
356
+		return $this->Status == 'Aborting';
357 357
 	}
358 358
 }
Please login to merge, or discard this patch.
code/jobs/DeployJob.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 	public static function sig_file_for_data_object($dataObject) {
14 14
 		$dir = DNData::inst()->getSignalDir();
15
-		if (!is_dir($dir)) {
15
+		if(!is_dir($dir)) {
16 16
 			`mkdir $dir`;
17 17
 		}
18 18
 		return sprintf(
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public function alarmHandler() {
43 43
 		$sigFile = $this->args['sigFile'];
44
-		if (file_exists($sigFile) && is_readable($sigFile) && is_writable($sigFile)) {
44
+		if(file_exists($sigFile) && is_readable($sigFile) && is_writable($sigFile)) {
45 45
 			$signal = (int)file_get_contents($sigFile);
46
-			if (is_int($signal) && in_array((int)$signal, [
46
+			if(is_int($signal) && in_array((int)$signal, [
47 47
 				// The following signals are trapped by both Resque and Rainforest.
48 48
 				SIGTERM,
49 49
 				SIGINT,
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 				SIGCONT
55 55
 			])) {
56 56
 				echo sprintf(
57
-					'[-] Signal "%s" received, delivering to own process group, PID "%s".' . PHP_EOL,
57
+					'[-] Signal "%s" received, delivering to own process group, PID "%s".'.PHP_EOL,
58 58
 					$signal,
59 59
 					getmypid()
60 60
 				);
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 		posix_setsid();
77 77
 
78 78
 		if(function_exists('pcntl_alarm') && function_exists('pcntl_signal')) {
79
-			if (!empty($this->args['sigFile'])) {
80
-				echo sprintf('[-] Signal file requested, polling "%s".' . PHP_EOL, $this->args['sigFile']);
79
+			if(!empty($this->args['sigFile'])) {
80
+				echo sprintf('[-] Signal file requested, polling "%s".'.PHP_EOL, $this->args['sigFile']);
81 81
 				declare(ticks = 1);
82 82
 				pcntl_signal(SIGALRM, [$this, 'alarmHandler']);
83 83
 				pcntl_alarm(1);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	}
90 90
 
91 91
 	public function perform() {
92
-		echo "[-] DeployJob starting" . PHP_EOL;
92
+		echo "[-] DeployJob starting".PHP_EOL;
93 93
 		$log = new DeploynautLogFile($this->args['logfile']);
94 94
 
95 95
 		$deployment = DNDeployment::get()->byID($this->args['deploymentID']);
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 				$this->args
124 124
 			);
125 125
 		} catch(Exception $e) {
126
-			echo "[-] DeployJob failed" . PHP_EOL;
126
+			echo "[-] DeployJob failed".PHP_EOL;
127 127
 			throw $e;
128 128
 		}
129 129
 		$this->updateStatus('Finished');
130
-		echo "[-] DeployJob finished" . PHP_EOL;
130
+		echo "[-] DeployJob finished".PHP_EOL;
131 131
 	}
132 132
 
133 133
 	/**
Please login to merge, or discard this patch.