@@ -117,7 +117,6 @@ |
||
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Return data about a particular {@link Member} of the stack for use in API response. |
120 | - |
|
121 | 120 | * Notes: |
122 | 121 | * 1) This method returns null instead of an array if the member doesn't exists anymore |
123 | 122 | * 2) 'role' can be null in the response. This is the case of an admin, or an operations |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $startedNice = null; |
41 | 41 | $startedAgo = null; |
42 | 42 | // we check first, before we do a expensive ->Nice() and ->Ago() |
43 | - if(!$deployment->DeployStarted) { |
|
43 | + if (!$deployment->DeployStarted) { |
|
44 | 44 | $started = $deployment->Created; |
45 | 45 | $startedNice = $deployment->obj('Created')->Nice(); |
46 | 46 | $startedAgo = $deployment->obj('Created')->Ago(); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | self::$_cache_members[$memberID] = \DataObject::get_by_id("Member", $memberID); |
146 | 146 | } |
147 | 147 | |
148 | - if(!self::$_cache_members[$memberID]) { |
|
148 | + if (!self::$_cache_members[$memberID]) { |
|
149 | 149 | return null; |
150 | 150 | } |
151 | 151 |
@@ -82,11 +82,11 @@ |
||
82 | 82 | |
83 | 83 | $base = Director::absoluteBaseURL(); |
84 | 84 | return [ |
85 | - 'basename' => Director::baseURL() . $this->getCurrentEnvironment()->Link(self::ACTION_OVERVIEW), |
|
85 | + 'basename' => Director::baseURL().$this->getCurrentEnvironment()->Link(self::ACTION_OVERVIEW), |
|
86 | 86 | 'dispatchers' => [ |
87 | - 'git' => $base . $this->getCurrentProject()->Link('git'), |
|
88 | - 'deploys' => $base . $this->getCurrentEnvironment()->Link('deploys'), |
|
89 | - 'approvals' => $base . $this->getCurrentEnvironment()->Link('approvals') |
|
87 | + 'git' => $base.$this->getCurrentProject()->Link('git'), |
|
88 | + 'deploys' => $base.$this->getCurrentEnvironment()->Link('deploys'), |
|
89 | + 'approvals' => $base.$this->getCurrentEnvironment()->Link('approvals') |
|
90 | 90 | ], |
91 | 91 | 'api_auth' => [ |
92 | 92 | 'name' => $this->getSecurityToken()->getName(), |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $cache = self::get_git_cache(); |
163 | 163 | // we only need to clear the tag cache since everything else is cached by SHA, that is for commit and |
164 | 164 | // commit message. |
165 | - $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['gitonomy', 'tags', 'project_' . $this->ID]); |
|
165 | + $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['gitonomy', 'tags', 'project_'.$this->ID]); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | return true; |
334 | 334 | } |
335 | 335 | |
336 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
336 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
337 | 337 | return $env->canRestore($member); |
338 | 338 | })->Count(); |
339 | 339 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | return true; |
355 | 355 | } |
356 | 356 | |
357 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
357 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
358 | 358 | return $env->canBackup($member); |
359 | 359 | })->Count(); |
360 | 360 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | return true; |
376 | 376 | } |
377 | 377 | |
378 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
378 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
379 | 379 | return $env->canUploadArchive($member); |
380 | 380 | })->Count(); |
381 | 381 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | return true; |
397 | 397 | } |
398 | 398 | |
399 | - return (bool) $this->Environments()->filterByCallback(function ($env) use ($member) { |
|
399 | + return (bool) $this->Environments()->filterByCallback(function($env) use ($member) { |
|
400 | 400 | return $env->canDownloadArchive($member); |
401 | 401 | })->Count(); |
402 | 402 | } |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | // Key-pair is available, use it. |
456 | 456 | $processEnv = [ |
457 | 457 | 'IDENT_KEY' => $this->getPrivateKeyPath(), |
458 | - 'GIT_SSH' => BASE_PATH . "/deploynaut/git-deploy.sh" |
|
458 | + 'GIT_SSH' => BASE_PATH."/deploynaut/git-deploy.sh" |
|
459 | 459 | ]; |
460 | 460 | } else { |
461 | 461 | $processEnv = []; |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | |
544 | 544 | $currentMember = self::$_current_member_cache; |
545 | 545 | return $this->Environments() |
546 | - ->filterByCallBack(function ($item) use ($currentMember) { |
|
546 | + ->filterByCallBack(function($item) use ($currentMember) { |
|
547 | 547 | return $item->canView($currentMember); |
548 | 548 | }); |
549 | 549 | } |
@@ -562,14 +562,14 @@ discard block |
||
562 | 562 | * @return false|DNDeployment |
563 | 563 | */ |
564 | 564 | public function currentBuilds() { |
565 | - if (!isset(self::$relation_cache['currentBuilds.' . $this->ID])) { |
|
565 | + if (!isset(self::$relation_cache['currentBuilds.'.$this->ID])) { |
|
566 | 566 | $currentBuilds = []; |
567 | 567 | foreach ($this->Environments() as $env) { |
568 | 568 | $currentBuilds[$env->Name] = $env->CurrentBuild(); |
569 | 569 | } |
570 | - self::$relation_cache['currentBuilds.' . $this->ID] = $currentBuilds; |
|
570 | + self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds; |
|
571 | 571 | } |
572 | - return self::$relation_cache['currentBuilds.' . $this->ID]; |
|
572 | + return self::$relation_cache['currentBuilds.'.$this->ID]; |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | */ |
824 | 824 | public function getPublicKeyPath() { |
825 | 825 | if ($privateKey = $this->getPrivateKeyPath()) { |
826 | - return $privateKey . '.pub'; |
|
826 | + return $privateKey.'.pub'; |
|
827 | 827 | } |
828 | 828 | return null; |
829 | 829 | } |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | if (!empty($keyDir)) { |
839 | 839 | $filter = FileNameFilter::create(); |
840 | 840 | $name = $filter->filter($this->Name); |
841 | - return $keyDir . '/' . $name; |
|
841 | + return $keyDir.'/'.$name; |
|
842 | 842 | } |
843 | 843 | return null; |
844 | 844 | } |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | $filter = FileNameFilter::create(); |
858 | 858 | $name = $filter->filter($this->Name); |
859 | 859 | |
860 | - return $this->DNData()->getKeyDir() . '/' . $name; |
|
860 | + return $this->DNData()->getKeyDir().'/'.$name; |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | /** |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | /* Look for each whitelisted hostname */ |
884 | 884 | foreach ($interfaces as $host => $interface) { |
885 | 885 | /* See if the CVS Path is for this hostname, followed by some junk (maybe a port), then the path */ |
886 | - if (preg_match('{^[^.]*' . $host . '(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) { |
|
886 | + if (preg_match('{^[^.]*'.$host.'(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) { |
|
887 | 887 | |
888 | 888 | $path = $match[2]; |
889 | 889 | |
@@ -894,10 +894,10 @@ discard block |
||
894 | 894 | $components = explode('.', $host); |
895 | 895 | |
896 | 896 | foreach ($regex as $pattern => $replacement) { |
897 | - $path = preg_replace('/' . $pattern . '/', $replacement, $path); |
|
897 | + $path = preg_replace('/'.$pattern.'/', $replacement, $path); |
|
898 | 898 | } |
899 | 899 | |
900 | - $uxurl = Controller::join_links($scheme . '://', $host, $path); |
|
900 | + $uxurl = Controller::join_links($scheme.'://', $host, $path); |
|
901 | 901 | |
902 | 902 | if (array_key_exists('commit', $interface) && $interface['commit'] == false) { |
903 | 903 | $commiturl = false; |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | // {@see DataObject::extendedCan()} |
1025 | 1025 | $isDone = $this->extend('isProjectReady'); |
1026 | 1026 | if ($isDone && is_array($isDone)) { |
1027 | - $isDone = array_filter($isDone, function ($val) { |
|
1027 | + $isDone = array_filter($isDone, function($val) { |
|
1028 | 1028 | return !is_null($val); |
1029 | 1029 | }); |
1030 | 1030 | |
@@ -1109,11 +1109,11 @@ discard block |
||
1109 | 1109 | return false; |
1110 | 1110 | } |
1111 | 1111 | |
1112 | - $cachekey = $this->ID . '_commit_' . $sha; |
|
1112 | + $cachekey = $this->ID.'_commit_'.$sha; |
|
1113 | 1113 | $cache = self::get_git_cache(); |
1114 | 1114 | if (!($result = $cache->load($cachekey))) { |
1115 | 1115 | $result = $repo->getCommit($sha); |
1116 | - $cache->save($result, $cachekey, ['gitonomy', 'commit', 'project_' . $this->ID]); |
|
1116 | + $cache->save($result, $cachekey, ['gitonomy', 'commit', 'project_'.$this->ID]); |
|
1117 | 1117 | } |
1118 | 1118 | return $result; |
1119 | 1119 | } |
@@ -1123,11 +1123,11 @@ discard block |
||
1123 | 1123 | * @return string |
1124 | 1124 | */ |
1125 | 1125 | public function getCommitMessage(\Gitonomy\Git\Commit $commit) { |
1126 | - $cachekey = $this->ID . '_message_' . $commit->getRevision(); |
|
1126 | + $cachekey = $this->ID.'_message_'.$commit->getRevision(); |
|
1127 | 1127 | $cache = self::get_git_cache(); |
1128 | 1128 | if (!($result = $cache->load($cachekey))) { |
1129 | 1129 | $result = $commit->getMessage(); |
1130 | - $cache->save($result, $cachekey, ['gitonomy', 'message', 'project_' . $this->ID]); |
|
1130 | + $cache->save($result, $cachekey, ['gitonomy', 'message', 'project_'.$this->ID]); |
|
1131 | 1131 | } |
1132 | 1132 | return $result; |
1133 | 1133 | } |
@@ -1139,11 +1139,11 @@ discard block |
||
1139 | 1139 | * @return string |
1140 | 1140 | */ |
1141 | 1141 | public function getCommitSubjectMessage(\Gitonomy\Git\Commit $commit) { |
1142 | - $cachekey = $this->ID . '_message_subject' . $commit->getRevision(); |
|
1142 | + $cachekey = $this->ID.'_message_subject'.$commit->getRevision(); |
|
1143 | 1143 | $cache = self::get_git_cache(); |
1144 | 1144 | if (!($result = $cache->load($cachekey))) { |
1145 | 1145 | $result = $commit->getSubjectMessage(); |
1146 | - $cache->save($result, $cachekey, ['gitonomy', 'message', 'project_' . $this->ID]); |
|
1146 | + $cache->save($result, $cachekey, ['gitonomy', 'message', 'project_'.$this->ID]); |
|
1147 | 1147 | } |
1148 | 1148 | return $result; |
1149 | 1149 | } |
@@ -1153,14 +1153,14 @@ discard block |
||
1153 | 1153 | * @return mixed |
1154 | 1154 | */ |
1155 | 1155 | public function getCommitTags(\Gitonomy\Git\Commit $commit) { |
1156 | - $cachekey = $this->ID . '_tags_' . $commit->getRevision(); |
|
1156 | + $cachekey = $this->ID.'_tags_'.$commit->getRevision(); |
|
1157 | 1157 | $cache = self::get_git_cache(); |
1158 | 1158 | $result = $cache->load($cachekey); |
1159 | 1159 | // we check against false, because in many cases the tag list is an empty array |
1160 | 1160 | if ($result === false) { |
1161 | 1161 | $repo = $this->getRepository(); |
1162 | 1162 | $result = $repo->getReferences()->resolveTags($commit->getRevision()); |
1163 | - $cache->save($result, $cachekey, ['gitonomy', 'tags', 'project_' . $this->ID]); |
|
1163 | + $cache->save($result, $cachekey, ['gitonomy', 'tags', 'project_'.$this->ID]); |
|
1164 | 1164 | } |
1165 | 1165 | return $result; |
1166 | 1166 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $currentBuild = $environment->CurrentBuild(); |
27 | 27 | $currentSha = $currentBuild ? $currentBuild->SHA : '-'; |
28 | - if($currentSha !== $options['sha']) { |
|
28 | + if ($currentSha !== $options['sha']) { |
|
29 | 29 | $strategy->setChange('Code version', $currentSha, $options['sha']); |
30 | 30 | } |
31 | 31 | $strategy->setActionTitle('Confirm deployment'); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | // Use a package generator if specified, otherwise run a direct deploy, which is the default behaviour |
68 | 68 | // if build_filename isn't specified |
69 | - if($this->packageGenerator) { |
|
69 | + if ($this->packageGenerator) { |
|
70 | 70 | $log->write(sprintf('Using package generator "%s"', get_class($this->packageGenerator))); |
71 | 71 | |
72 | 72 | try { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | throw $e; |
77 | 77 | } |
78 | 78 | |
79 | - if(empty($args['build_filename'])) { |
|
79 | + if (empty($args['build_filename'])) { |
|
80 | 80 | throw new RuntimeException('Failed to generate package.'); |
81 | 81 | } |
82 | 82 | } |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | $cleanup->run(function($type, $buffer) use($log) { |
120 | 120 | $log->write($buffer); |
121 | 121 | }); |
122 | - if(!$cleanup->isSuccessful()) { |
|
122 | + if (!$cleanup->isSuccessful()) { |
|
123 | 123 | $this->extend('cleanupFailure', $environment, $sha, $log, $project); |
124 | 124 | $log->write('Warning: Cleanup failed, but fine to continue. Needs manual cleanup sometime.'); |
125 | 125 | } |
126 | 126 | |
127 | 127 | $this->extend('deployEnd', $environment, $sha, $log, $project); |
128 | 128 | |
129 | - if ($error!==null) { |
|
129 | + if ($error !== null) { |
|
130 | 130 | throw new RuntimeException($error); |
131 | 131 | } |
132 | 132 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $command->run(function($type, $buffer) use($log) { |
181 | 181 | $log->write($buffer); |
182 | 182 | }); |
183 | - if(!$command->isSuccessful()) { |
|
183 | + if (!$command->isSuccessful()) { |
|
184 | 184 | $this->extend('maintenanceEnableFailure', $environment, $log); |
185 | 185 | throw new RuntimeException($command->getErrorOutput()); |
186 | 186 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $command->run(function($type, $buffer) use($log) { |
197 | 197 | $log->write($buffer); |
198 | 198 | }); |
199 | - if(!$command->isSuccessful()) { |
|
199 | + if (!$command->isSuccessful()) { |
|
200 | 200 | $this->extend('maintenanceDisableFailure', $environment, $log); |
201 | 201 | throw new RuntimeException($command->getErrorOutput()); |
202 | 202 | } |
@@ -218,25 +218,25 @@ discard block |
||
218 | 218 | * @inheritdoc |
219 | 219 | */ |
220 | 220 | public function dataTransfer(\DNDataTransfer $dataTransfer, \DeploynautLogFile $log) { |
221 | - if($dataTransfer->Direction == 'get') { |
|
221 | + if ($dataTransfer->Direction == 'get') { |
|
222 | 222 | $this->dataTransferBackup($dataTransfer, $log); |
223 | 223 | } else { |
224 | 224 | $environment = $dataTransfer->Environment(); |
225 | 225 | $project = $environment->Project(); |
226 | - $workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID; |
|
226 | + $workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID; |
|
227 | 227 | $archive = $dataTransfer->DataArchive(); |
228 | 228 | |
229 | 229 | // extract the sspak contents, we'll need these so capistrano can restore that content |
230 | 230 | try { |
231 | 231 | $archive->extractArchive($workingDir); |
232 | - } catch(Exception $e) { |
|
232 | + } catch (Exception $e) { |
|
233 | 233 | $log->write($e->getMessage()); |
234 | 234 | throw new RuntimeException($e->getMessage()); |
235 | 235 | } |
236 | 236 | |
237 | 237 | // validate the contents match the requested transfer mode |
238 | 238 | $result = $archive->validateArchiveContents($dataTransfer->Mode); |
239 | - if(!$result->valid()) { |
|
239 | + if (!$result->valid()) { |
|
240 | 240 | // do some cleaning, get rid of the extracted archive lying around |
241 | 241 | $process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
242 | 242 | $process->setTimeout(120); |
@@ -266,41 +266,41 @@ discard block |
||
266 | 266 | $name = $environment->getFullName(); |
267 | 267 | $env = $environment->Project()->getProcessEnv(); |
268 | 268 | |
269 | - if(!$args) { |
|
269 | + if (!$args) { |
|
270 | 270 | $args = array(); |
271 | 271 | } |
272 | - $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/'); |
|
272 | + $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/'); |
|
273 | 273 | $args['environment_id'] = $environment->ID; |
274 | 274 | |
275 | 275 | // Inject env string directly into the command. |
276 | 276 | // Capistrano doesn't like the $process->setEnv($env) we'd normally do below. |
277 | 277 | $envString = ''; |
278 | - if(!empty($env)) { |
|
278 | + if (!empty($env)) { |
|
279 | 279 | $envString .= 'env '; |
280 | - foreach($env as $key => $value) { |
|
280 | + foreach ($env as $key => $value) { |
|
281 | 281 | $envString .= "$key=\"$value\" "; |
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | 285 | $data = DNData::inst(); |
286 | 286 | // Generate a capfile from a template |
287 | - $capTemplate = file_get_contents(BASE_PATH . '/deploynaut/Capfile.template'); |
|
287 | + $capTemplate = file_get_contents(BASE_PATH.'/deploynaut/Capfile.template'); |
|
288 | 288 | $cap = str_replace( |
289 | 289 | array('<config root>', '<ssh key>', '<base path>'), |
290 | 290 | array($data->getEnvironmentDir(), DEPLOYNAUT_SSH_KEY, BASE_PATH), |
291 | 291 | $capTemplate |
292 | 292 | ); |
293 | 293 | |
294 | - if(defined('DEPLOYNAUT_CAPFILE')) { |
|
294 | + if (defined('DEPLOYNAUT_CAPFILE')) { |
|
295 | 295 | $capFile = DEPLOYNAUT_CAPFILE; |
296 | 296 | } else { |
297 | - $capFile = ASSETS_PATH . '/Capfile'; |
|
297 | + $capFile = ASSETS_PATH.'/Capfile'; |
|
298 | 298 | } |
299 | 299 | file_put_contents($capFile, $cap); |
300 | 300 | |
301 | - $command = "{$envString}cap -f " . escapeshellarg($capFile) . " -vv $name $action ROLES=$roles"; |
|
302 | - foreach($args as $argName => $argVal) { |
|
303 | - $command .= ' -s ' . escapeshellarg($argName) . '=' . escapeshellarg($argVal); |
|
301 | + $command = "{$envString}cap -f ".escapeshellarg($capFile)." -vv $name $action ROLES=$roles"; |
|
302 | + foreach ($args as $argName => $argVal) { |
|
303 | + $command .= ' -s '.escapeshellarg($argName).'='.escapeshellarg($argVal); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | $log->write(sprintf('Running command: %s', $command)); |
@@ -334,16 +334,16 @@ discard block |
||
334 | 334 | $filepathBase = $dataArchive->generateFilepath($dataTransfer); |
335 | 335 | mkdir($filepathBase, 0700, true); |
336 | 336 | |
337 | - $databasePath = $filepathBase . DIRECTORY_SEPARATOR . 'database.sql.gz'; |
|
337 | + $databasePath = $filepathBase.DIRECTORY_SEPARATOR.'database.sql.gz'; |
|
338 | 338 | |
339 | 339 | // Backup database |
340 | - if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
340 | + if (in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
341 | 341 | $log->write(sprintf('Backup of database from "%s" started', $name)); |
342 | 342 | $command = $this->getCommand('data:getdb', 'db', $environment, array('data_path' => $databasePath), $log); |
343 | 343 | $command->run(function($type, $buffer) use($log) { |
344 | 344 | $log->write($buffer); |
345 | 345 | }); |
346 | - if(!$command->isSuccessful()) { |
|
346 | + if (!$command->isSuccessful()) { |
|
347 | 347 | $this->extend('dataTransferFailure', $environment, $log); |
348 | 348 | throw new RuntimeException($command->getErrorOutput()); |
349 | 349 | } |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | } |
352 | 352 | |
353 | 353 | // Backup assets |
354 | - if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
354 | + if (in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
355 | 355 | $log->write(sprintf('Backup of assets from "%s" started', $name)); |
356 | 356 | $command = $this->getCommand('data:getassets', 'web', $environment, array('data_path' => $filepathBase), $log); |
357 | 357 | $command->run(function($type, $buffer) use($log) { |
358 | 358 | $log->write($buffer); |
359 | 359 | }); |
360 | - if(!$command->isSuccessful()) { |
|
360 | + if (!$command->isSuccessful()) { |
|
361 | 361 | $this->extend('dataTransferFailure', $environment, $log); |
362 | 362 | throw new RuntimeException($command->getErrorOutput()); |
363 | 363 | } |
@@ -372,12 +372,12 @@ discard block |
||
372 | 372 | $log->write('Creating sspak...'); |
373 | 373 | |
374 | 374 | $sspakFilename = sprintf('%s.sspak', $dataArchive->generateFilename($dataTransfer)); |
375 | - $sspakFilepath = $filepathBase . DIRECTORY_SEPARATOR . $sspakFilename; |
|
375 | + $sspakFilepath = $filepathBase.DIRECTORY_SEPARATOR.$sspakFilename; |
|
376 | 376 | |
377 | 377 | try { |
378 | 378 | $dataArchive->attachFile($sspakFilepath, $dataTransfer); |
379 | 379 | $dataArchive->setArchiveFromFiles($filepathBase); |
380 | - } catch(Exception $e) { |
|
380 | + } catch (Exception $e) { |
|
381 | 381 | $log->write($e->getMessage()); |
382 | 382 | throw new RuntimeException($e->getMessage()); |
383 | 383 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $process = new AbortableProcess(sprintf('rm -rf %s/assets && rm -f %s', escapeshellarg($filepathBase), escapeshellarg($databasePath))); |
389 | 389 | $process->setTimeout(120); |
390 | 390 | $process->run(); |
391 | - if(!$process->isSuccessful()) { |
|
391 | + if (!$process->isSuccessful()) { |
|
392 | 392 | $log->write('Could not delete temporary files'); |
393 | 393 | throw new RuntimeException($process->getErrorOutput()); |
394 | 394 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $command->run(function($type, $buffer) use($log) { |
408 | 408 | $log->write($buffer); |
409 | 409 | }); |
410 | - if(!$command->isSuccessful()) { |
|
410 | + if (!$command->isSuccessful()) { |
|
411 | 411 | $log->write(sprintf('Rebuild of "%s" failed: %s', $name, $command->getErrorOutput())); |
412 | 412 | throw new RuntimeException($command->getErrorOutput()); |
413 | 413 | } |
@@ -437,14 +437,14 @@ discard block |
||
437 | 437 | }; |
438 | 438 | |
439 | 439 | // Restore database into target environment |
440 | - if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
440 | + if (in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
441 | 441 | $log->write(sprintf('Restore of database to "%s" started', $name)); |
442 | - $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'database.sql'); |
|
442 | + $args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'database.sql'); |
|
443 | 443 | $command = $this->getCommand('data:pushdb', 'db', $environment, $args, $log); |
444 | 444 | $command->run(function($type, $buffer) use($log) { |
445 | 445 | $log->write($buffer); |
446 | 446 | }); |
447 | - if(!$command->isSuccessful()) { |
|
447 | + if (!$command->isSuccessful()) { |
|
448 | 448 | $cleanupFn(); |
449 | 449 | $log->write(sprintf('Restore of database to "%s" failed: %s', $name, $command->getErrorOutput())); |
450 | 450 | $this->extend('dataTransferFailure', $environment, $log); |
@@ -454,14 +454,14 @@ discard block |
||
454 | 454 | } |
455 | 455 | |
456 | 456 | // Restore assets into target environment |
457 | - if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
457 | + if (in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
458 | 458 | $log->write(sprintf('Restore of assets to "%s" started', $name)); |
459 | - $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'assets'); |
|
459 | + $args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'assets'); |
|
460 | 460 | $command = $this->getCommand('data:pushassets', 'web', $environment, $args, $log); |
461 | 461 | $command->run(function($type, $buffer) use($log) { |
462 | 462 | $log->write($buffer); |
463 | 463 | }); |
464 | - if(!$command->isSuccessful()) { |
|
464 | + if (!$command->isSuccessful()) { |
|
465 | 465 | $cleanupFn(); |
466 | 466 | $log->write(sprintf('Restore of assets to "%s" failed: %s', $name, $command->getErrorOutput())); |
467 | 467 | $this->extend('dataTransferFailure', $environment, $log); |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | $timeout = 600; |
487 | 487 | $tick = 60; |
488 | 488 | |
489 | - if(!$url) { |
|
489 | + if (!$url) { |
|
490 | 490 | $log->write('Skipping site accessible check: no URL found.'); |
491 | 491 | return true; |
492 | 492 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | // query the site every second. Note that if the URL doesn't respond, |
518 | 518 | // curl_exec will take 5 seconds to timeout (see CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT above) |
519 | 519 | do { |
520 | - if(time() > $start + $timeout) { |
|
520 | + if (time() > $start + $timeout) { |
|
521 | 521 | $log->write(sprintf(' * Failed: check for %s timed out after %smin', $url, $timeout / 60)); |
522 | 522 | return false; |
523 | 523 | } |
@@ -526,13 +526,13 @@ discard block |
||
526 | 526 | |
527 | 527 | // check the HTTP response code for HTTP protocols |
528 | 528 | $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
529 | - if($status && !in_array($status, [500, 501, 502, 503, 504])) { |
|
529 | + if ($status && !in_array($status, [500, 501, 502, 503, 504])) { |
|
530 | 530 | $success = true; |
531 | 531 | } |
532 | 532 | |
533 | 533 | // check for any curl errors, mostly for checking the response state of non-HTTP protocols, |
534 | 534 | // but applies to checks of any protocol |
535 | - if($response && !curl_errno($ch)) { |
|
535 | + if ($response && !curl_errno($ch)) { |
|
536 | 536 | $success = true; |
537 | 537 | } |
538 | 538 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | sleep(1); |
563 | - } while(!$success); |
|
563 | + } while (!$success); |
|
564 | 564 | |
565 | 565 | curl_close($ch); |
566 | 566 | $log->write(' * Success: site is accessible!'); |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | public function run($request) { |
6 | 6 | $log = function($message) { |
7 | - $message = sprintf('[%s] ', date('Y-m-d H:i:s')) . $message; |
|
8 | - echo $message . PHP_EOL; |
|
7 | + $message = sprintf('[%s] ', date('Y-m-d H:i:s')).$message; |
|
8 | + echo $message.PHP_EOL; |
|
9 | 9 | }; |
10 | 10 | |
11 | 11 | if (!Director::is_cli()) { |