@@ -158,10 +158,10 @@ |
||
158 | 158 | /** |
159 | 159 | * Grabs a list of projects from the env directory. The projects |
160 | 160 | * in the builds directory alone will not be picked up. |
161 | - * Returns an array of paths |
|
161 | + * Returns an array of paths |
|
162 | 162 | * |
163 | 163 | * @return array |
164 | - */ |
|
164 | + */ |
|
165 | 165 | public function getProjectPaths() { |
166 | 166 | $paths = array(); |
167 | 167 | if(!file_exists($this->getEnvironmentDir())) { |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | public function getProjectPaths() { |
166 | 166 | $paths = array(); |
167 | 167 | if(!file_exists($this->getEnvironmentDir())) { |
168 | - throw new Exception('The environment directory '.$this->getEnvironmentDir().' doesn\'t exist. Create it first and add some projects to it.'); |
|
168 | + throw new Exception('The environment directory ' . $this->getEnvironmentDir() . ' doesn\'t exist. Create it first and add some projects to it.'); |
|
169 | 169 | } |
170 | 170 | foreach(scandir($this->getEnvironmentDir()) as $project) { |
171 | 171 | // Exlcude dot-prefixed directories (.git was getting in the way) |
172 | 172 | if(preg_match('/^[^\.]/', $project)) { |
173 | - $path = $this->getEnvironmentDir().'/'.$project; |
|
174 | - if(is_dir($path) && $project!='.' && $project!='..') { |
|
173 | + $path = $this->getEnvironmentDir() . '/' . $project; |
|
174 | + if(is_dir($path) && $project != '.' && $project != '..') { |
|
175 | 175 | $paths[] = $project; |
176 | 176 | } |
177 | 177 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | $paths = array(); |
191 | 191 | if(!file_exists($baseDir)) { |
192 | - throw new Exception('Environment directory '.$baseDir.' doesn\'t exist. Create it first.'); |
|
192 | + throw new Exception('Environment directory ' . $baseDir . ' doesn\'t exist. Create it first.'); |
|
193 | 193 | } |
194 | 194 | // Search the directory for config files. |
195 | 195 | foreach(scandir($baseDir) as $environmentFile) { |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | parent::__construct(); |
53 | 53 | |
54 | 54 | // Better to use injector to set these |
55 | - if(func_num_args() == 0) return; |
|
55 | + if(func_num_args() == 0) { |
|
56 | + return; |
|
57 | + } |
|
56 | 58 | Deprecation::notice( |
57 | 59 | '1.2.0', |
58 | 60 | "Don't construct DNData with parameters. Assign settings via properties instead" |
@@ -78,7 +80,9 @@ discard block |
||
78 | 80 | * @param string $environmentDir |
79 | 81 | */ |
80 | 82 | public function setEnvironmentDir($environmentDir) { |
81 | - if($environmentDir[0] != "/") $environmentDir = BASE_PATH . '/' . $environmentDir; |
|
83 | + if($environmentDir[0] != "/") { |
|
84 | + $environmentDir = BASE_PATH . '/' . $environmentDir; |
|
85 | + } |
|
82 | 86 | $this->environmentDir = realpath($environmentDir) ?: $environmentDir; |
83 | 87 | } |
84 | 88 | |
@@ -97,7 +101,9 @@ discard block |
||
97 | 101 | * @param string $keyDir |
98 | 102 | */ |
99 | 103 | public function setKeyDir($keyDir) { |
100 | - if($keyDir[0] != "/") $keyDir = BASE_PATH . '/' . $keyDir; |
|
104 | + if($keyDir[0] != "/") { |
|
105 | + $keyDir = BASE_PATH . '/' . $keyDir; |
|
106 | + } |
|
101 | 107 | $this->keyDir = realpath($keyDir) ?: $keyDir; |
102 | 108 | } |
103 | 109 | |
@@ -137,7 +143,9 @@ discard block |
||
137 | 143 | * @param string $transferDir |
138 | 144 | */ |
139 | 145 | public function setDataTransferDir($transferDir) { |
140 | - if($transferDir[0] != "/") $transferDir = BASE_PATH . '/' . $transferDir; |
|
146 | + if($transferDir[0] != "/") { |
|
147 | + $transferDir = BASE_PATH . '/' . $transferDir; |
|
148 | + } |
|
141 | 149 | if(strpos($transferDir, ASSETS_PATH) === false) { |
142 | 150 | throw new LogicException(sprintf( |
143 | 151 | 'DNData::dataTransferDir needs to be located within <webroot>assets/ (location: %s)', |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @return boolean true if $member can upload archives linked to this environment, false if they can't. |
255 | 255 | */ |
256 | 256 | public function canMoveTo($targetEnv, $member = null) { |
257 | - if ($this->Environment()->Project()->ID!=$targetEnv->Project()->ID) { |
|
257 | + if($this->Environment()->Project()->ID != $targetEnv->Project()->ID) { |
|
258 | 258 | // We don't permit moving snapshots between projects at this stage. |
259 | 259 | return false; |
260 | 260 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | if(Permission::checkMember($member, 'ADMIN')) return true; |
267 | 267 | |
268 | 268 | // Checks if the user can actually access the archive. |
269 | - if (!$this->canDownload($member)) return false; |
|
269 | + if(!$this->canDownload($member)) return false; |
|
270 | 270 | |
271 | 271 | // Hooks into ArchiveUploaders permission to prevent proliferation of permission checkboxes. |
272 | 272 | // Bypasses the quota check - we don't need to check for it as long as we move the snapshot within the project. |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $archive = $this; |
285 | 285 | $envs = $this->Environment()->Project()->DNEnvironmentList() |
286 | 286 | ->filterByCallback(function($item) use ($archive) { |
287 | - return $archive->EnvironmentID!=$item->ID && $archive->canMoveTo($item); |
|
287 | + return $archive->EnvironmentID != $item->ID && $archive->canMoveTo($item); |
|
288 | 288 | }); |
289 | 289 | |
290 | 290 | return $envs; |
@@ -207,7 +207,9 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function canRestore($member = null) { |
209 | 209 | $memberID = $member ? $member->ID : Member::currentUserID(); |
210 | - if(!$memberID) return false; |
|
210 | + if(!$memberID) { |
|
211 | + return false; |
|
212 | + } |
|
211 | 213 | |
212 | 214 | $key = $memberID . '-' . $this->EnvironmentID; |
213 | 215 | if(!isset(self::$_cache_can_restore[$key])) { |
@@ -226,7 +228,9 @@ discard block |
||
226 | 228 | */ |
227 | 229 | public function canDownload($member = null) { |
228 | 230 | $memberID = $member ? $member->ID : Member::currentUserID(); |
229 | - if(!$memberID) return false; |
|
231 | + if(!$memberID) { |
|
232 | + return false; |
|
233 | + } |
|
230 | 234 | |
231 | 235 | $key = $memberID . '-' . $this->EnvironmentID; |
232 | 236 | if(!isset(self::$_cache_can_download[$key])) { |
@@ -259,14 +263,23 @@ discard block |
||
259 | 263 | return false; |
260 | 264 | } |
261 | 265 | |
262 | - if(!$member) $member = Member::currentUser(); |
|
263 | - if(!$member) return false; // Must be logged in to check permissions |
|
266 | + if(!$member) { |
|
267 | + $member = Member::currentUser(); |
|
268 | + } |
|
269 | + if(!$member) { |
|
270 | + return false; |
|
271 | + } |
|
272 | + // Must be logged in to check permissions |
|
264 | 273 | |
265 | 274 | // Admin can always move. |
266 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
275 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
276 | + return true; |
|
277 | + } |
|
267 | 278 | |
268 | 279 | // Checks if the user can actually access the archive. |
269 | - if (!$this->canDownload($member)) return false; |
|
280 | + if (!$this->canDownload($member)) { |
|
281 | + return false; |
|
282 | + } |
|
270 | 283 | |
271 | 284 | // Hooks into ArchiveUploaders permission to prevent proliferation of permission checkboxes. |
272 | 285 | // Bypasses the quota check - we don't need to check for it as long as we move the snapshot within the project. |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | public function getCommits() { |
46 | - if (!isset($this->env)) { |
|
46 | + if(!isset($this->env)) { |
|
47 | 47 | $this->environmentNotSetException(); |
48 | 48 | } |
49 | 49 | $successfulCommits = |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function getLatestCommit() { |
57 | - if (!isset($this->env)) { |
|
57 | + if(!isset($this->env)) { |
|
58 | 58 | $this->environmentNotSetException(); |
59 | 59 | } |
60 | 60 | $commits = $this->getCommits(); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | public static $cache = array(); |
8 | 8 | |
9 | 9 | public static function getIncludingBranches($commit) { |
10 | - $cacheKey = 'getIncludingBranches-' .$commit->getRepository()->getPath() . '-' . $commit->gethash(); |
|
10 | + $cacheKey = 'getIncludingBranches-' . $commit->getRepository()->getPath() . '-' . $commit->gethash(); |
|
11 | 11 | if(!isset(self::$cache[$cacheKey])) { |
12 | 12 | self::$cache[$cacheKey] = $commit->getIncludingBranches(); |
13 | 13 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This class will queue a ping job and also proxy to the log file of that output |
|
4 | - */ |
|
3 | + * This class will queue a ping job and also proxy to the log file of that output |
|
4 | + */ |
|
5 | 5 | class DNPing extends DataObject { |
6 | 6 | |
7 | 7 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | case 'Queued': |
48 | - if ($this->Pipeline()->SkipSnapshot) { |
|
48 | + if($this->Pipeline()->SkipSnapshot) { |
|
49 | 49 | return $this->startDeploy(); |
50 | 50 | } else { |
51 | 51 | return $this->createSnapshot(); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | // Skip deployment for dry run |
86 | 86 | if($this->Pipeline()->DryRun) { |
87 | - $this->log("[Skipped] Create DNDeployment for SHA ".$pipeline->SHA); |
|
87 | + $this->log("[Skipped] Create DNDeployment for SHA " . $pipeline->SHA); |
|
88 | 88 | $this->write(); |
89 | 89 | return true; |
90 | 90 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | // check if we have timed out |
41 | - if ($this->isTimedOut()) { |
|
41 | + if($this->isTimedOut()) { |
|
42 | 42 | $this->log(sprintf(_t('EmergencyRollbackStep.ROLLBACKTIMEOUT', |
43 | 43 | "{$this->Title} is older than %s seconds and has timed out"), |
44 | 44 | $this->MaxDuration)); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | ); |
86 | 86 | } |
87 | 87 | |
88 | - if ($this->Status == 'Queued') { |
|
88 | + if($this->Status == 'Queued') { |
|
89 | 89 | $this->start(); |
90 | 90 | } |
91 | 91 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $this->write(); |
97 | 97 | |
98 | 98 | // Rollback itself is handled by the Pipeline object. This step will be marked as failed. |
99 | - if ($this->Pipeline()->isRunning()) { |
|
99 | + if($this->Pipeline()->isRunning()) { |
|
100 | 100 | $this->Pipeline()->markFailed(); |
101 | 101 | return true; |
102 | 102 | } else { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function beginRollbackWindow() { |
129 | 129 | $this->Status = 'Started'; |
130 | - if (!$this->Started) $this->Started = SS_Datetime::now()->Rfc2822(); |
|
130 | + if(!$this->Started) $this->Started = SS_Datetime::now()->Rfc2822(); |
|
131 | 131 | $this->log(_t('EmergencyRollbackStep.BEGINROLLBACKWINDOW', |
132 | 132 | "{$this->Title} is beginning a rollback window...")); |
133 | 133 | $this->write(); |
@@ -127,7 +127,9 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function beginRollbackWindow() { |
129 | 129 | $this->Status = 'Started'; |
130 | - if (!$this->Started) $this->Started = SS_Datetime::now()->Rfc2822(); |
|
130 | + if (!$this->Started) { |
|
131 | + $this->Started = SS_Datetime::now()->Rfc2822(); |
|
132 | + } |
|
131 | 133 | $this->log(_t('EmergencyRollbackStep.BEGINROLLBACKWINDOW', |
132 | 134 | "{$this->Title} is beginning a rollback window...")); |
133 | 135 | $this->write(); |
@@ -138,7 +140,9 @@ discard block |
||
138 | 140 | |
139 | 141 | public function getRunningDescription() { |
140 | 142 | // Don't show options if this step has already been confirmed |
141 | - if($this->RolledBack) return; |
|
143 | + if($this->RolledBack) { |
|
144 | + return; |
|
145 | + } |
|
142 | 146 | |
143 | 147 | return _t('EmergencyRollbackStep.RUNNINGDESCRIPTION', |
144 | 148 | 'You may now roll back to the previous version, if needed.'); |
@@ -41,7 +41,9 @@ |
||
41 | 41 | if($this->Started) { |
42 | 42 | $started = intval($this->dbObject('Started')->Format('U')); |
43 | 43 | $now = intval(SS_Datetime::now()->Format('U')); |
44 | - if($started && $now) return $now - $started; |
|
44 | + if($started && $now) { |
|
45 | + return $now - $started; |
|
46 | + } |
|
45 | 47 | } |
46 | 48 | return 0; |
47 | 49 | } |
@@ -219,7 +219,7 @@ |
||
219 | 219 | * @return boolean |
220 | 220 | */ |
221 | 221 | protected function doRestoreDB() { |
222 | - if ($this->Pipeline()->SkipSnapshot) return false; |
|
222 | + if($this->Pipeline()->SkipSnapshot) return false; |
|
223 | 223 | |
224 | 224 | return $this->getConfigSetting('RestoreDB') && $this->Pipeline()->PreviousSnapshot(); |
225 | 225 | } |
@@ -219,7 +219,9 @@ |
||
219 | 219 | * @return boolean |
220 | 220 | */ |
221 | 221 | protected function doRestoreDB() { |
222 | - if ($this->Pipeline()->SkipSnapshot) return false; |
|
222 | + if ($this->Pipeline()->SkipSnapshot) { |
|
223 | + return false; |
|
224 | + } |
|
223 | 225 | |
224 | 226 | return $this->getConfigSetting('RestoreDB') && $this->Pipeline()->PreviousSnapshot(); |
225 | 227 | } |