@@ -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,7 +119,7 @@ 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 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $command->run(function($type, $buffer) use($log) { |
| 195 | 195 | $log->write($buffer); |
| 196 | 196 | }); |
| 197 | - if(!$command->isSuccessful()) { |
|
| 197 | + if (!$command->isSuccessful()) { |
|
| 198 | 198 | $this->extend('maintenanceEnableFailure', $environment, $log); |
| 199 | 199 | throw new RuntimeException($command->getErrorOutput()); |
| 200 | 200 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $command->run(function($type, $buffer) use($log) { |
| 211 | 211 | $log->write($buffer); |
| 212 | 212 | }); |
| 213 | - if(!$command->isSuccessful()) { |
|
| 213 | + if (!$command->isSuccessful()) { |
|
| 214 | 214 | $this->extend('maintenanceDisableFailure', $environment, $log); |
| 215 | 215 | throw new RuntimeException($command->getErrorOutput()); |
| 216 | 216 | } |
@@ -232,25 +232,25 @@ discard block |
||
| 232 | 232 | * @inheritdoc |
| 233 | 233 | */ |
| 234 | 234 | public function dataTransfer(\DNDataTransfer $dataTransfer, \DeploynautLogFile $log) { |
| 235 | - if($dataTransfer->Direction == 'get') { |
|
| 235 | + if ($dataTransfer->Direction == 'get') { |
|
| 236 | 236 | $this->dataTransferBackup($dataTransfer, $log); |
| 237 | 237 | } else { |
| 238 | 238 | $environment = $dataTransfer->Environment(); |
| 239 | 239 | $project = $environment->Project(); |
| 240 | - $workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID; |
|
| 240 | + $workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID; |
|
| 241 | 241 | $archive = $dataTransfer->DataArchive(); |
| 242 | 242 | |
| 243 | 243 | // extract the sspak contents, we'll need these so capistrano can restore that content |
| 244 | 244 | try { |
| 245 | 245 | $archive->extractArchive($workingDir); |
| 246 | - } catch(Exception $e) { |
|
| 246 | + } catch (Exception $e) { |
|
| 247 | 247 | $log->write($e->getMessage()); |
| 248 | 248 | throw new RuntimeException($e->getMessage()); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // validate the contents match the requested transfer mode |
| 252 | 252 | $result = $archive->validateArchiveContents($dataTransfer->Mode); |
| 253 | - if(!$result->valid()) { |
|
| 253 | + if (!$result->valid()) { |
|
| 254 | 254 | // do some cleaning, get rid of the extracted archive lying around |
| 255 | 255 | $process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
| 256 | 256 | $process->setTimeout(120); |
@@ -280,41 +280,41 @@ discard block |
||
| 280 | 280 | $name = $environment->getFullName(); |
| 281 | 281 | $env = $environment->Project()->getProcessEnv(); |
| 282 | 282 | |
| 283 | - if(!$args) { |
|
| 283 | + if (!$args) { |
|
| 284 | 284 | $args = array(); |
| 285 | 285 | } |
| 286 | - $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/'); |
|
| 286 | + $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/'); |
|
| 287 | 287 | $args['environment_id'] = $environment->ID; |
| 288 | 288 | |
| 289 | 289 | // Inject env string directly into the command. |
| 290 | 290 | // Capistrano doesn't like the $process->setEnv($env) we'd normally do below. |
| 291 | 291 | $envString = ''; |
| 292 | - if(!empty($env)) { |
|
| 292 | + if (!empty($env)) { |
|
| 293 | 293 | $envString .= 'env '; |
| 294 | - foreach($env as $key => $value) { |
|
| 294 | + foreach ($env as $key => $value) { |
|
| 295 | 295 | $envString .= "$key=\"$value\" "; |
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | $data = DNData::inst(); |
| 300 | 300 | // Generate a capfile from a template |
| 301 | - $capTemplate = file_get_contents(BASE_PATH . '/deploynaut/Capfile.template'); |
|
| 301 | + $capTemplate = file_get_contents(BASE_PATH.'/deploynaut/Capfile.template'); |
|
| 302 | 302 | $cap = str_replace( |
| 303 | 303 | array('<config root>', '<ssh key>', '<base path>'), |
| 304 | 304 | array($data->getEnvironmentDir(), DEPLOYNAUT_SSH_KEY, BASE_PATH), |
| 305 | 305 | $capTemplate |
| 306 | 306 | ); |
| 307 | 307 | |
| 308 | - if(defined('DEPLOYNAUT_CAPFILE')) { |
|
| 308 | + if (defined('DEPLOYNAUT_CAPFILE')) { |
|
| 309 | 309 | $capFile = DEPLOYNAUT_CAPFILE; |
| 310 | 310 | } else { |
| 311 | - $capFile = ASSETS_PATH . '/Capfile'; |
|
| 311 | + $capFile = ASSETS_PATH.'/Capfile'; |
|
| 312 | 312 | } |
| 313 | 313 | file_put_contents($capFile, $cap); |
| 314 | 314 | |
| 315 | - $command = "{$envString}cap -f " . escapeshellarg($capFile) . " -vv $name $action ROLES=$roles"; |
|
| 316 | - foreach($args as $argName => $argVal) { |
|
| 317 | - $command .= ' -s ' . escapeshellarg($argName) . '=' . escapeshellarg($argVal); |
|
| 315 | + $command = "{$envString}cap -f ".escapeshellarg($capFile)." -vv $name $action ROLES=$roles"; |
|
| 316 | + foreach ($args as $argName => $argVal) { |
|
| 317 | + $command .= ' -s '.escapeshellarg($argName).'='.escapeshellarg($argVal); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $log->write(sprintf('Running command: %s', $command)); |
@@ -348,16 +348,16 @@ discard block |
||
| 348 | 348 | $filepathBase = $dataArchive->generateFilepath($dataTransfer); |
| 349 | 349 | mkdir($filepathBase, 0700, true); |
| 350 | 350 | |
| 351 | - $databasePath = $filepathBase . DIRECTORY_SEPARATOR . 'database.sql.gz'; |
|
| 351 | + $databasePath = $filepathBase.DIRECTORY_SEPARATOR.'database.sql.gz'; |
|
| 352 | 352 | |
| 353 | 353 | // Backup database |
| 354 | - if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 354 | + if (in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 355 | 355 | $log->write(sprintf('Backup of database from "%s" started', $name)); |
| 356 | 356 | $command = $this->getCommand('data:getdb', 'db', $environment, array('data_path' => $databasePath), $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 | } |
@@ -365,13 +365,13 @@ discard block |
||
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | // Backup assets |
| 368 | - if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 368 | + if (in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 369 | 369 | $log->write(sprintf('Backup of assets from "%s" started', $name)); |
| 370 | 370 | $command = $this->getCommand('data:getassets', 'web', $environment, array('data_path' => $filepathBase), $log); |
| 371 | 371 | $command->run(function($type, $buffer) use($log) { |
| 372 | 372 | $log->write($buffer); |
| 373 | 373 | }); |
| 374 | - if(!$command->isSuccessful()) { |
|
| 374 | + if (!$command->isSuccessful()) { |
|
| 375 | 375 | $this->extend('dataTransferFailure', $environment, $log); |
| 376 | 376 | throw new RuntimeException($command->getErrorOutput()); |
| 377 | 377 | } |
@@ -386,12 +386,12 @@ discard block |
||
| 386 | 386 | $log->write('Creating sspak...'); |
| 387 | 387 | |
| 388 | 388 | $sspakFilename = sprintf('%s.sspak', $dataArchive->generateFilename($dataTransfer)); |
| 389 | - $sspakFilepath = $filepathBase . DIRECTORY_SEPARATOR . $sspakFilename; |
|
| 389 | + $sspakFilepath = $filepathBase.DIRECTORY_SEPARATOR.$sspakFilename; |
|
| 390 | 390 | |
| 391 | 391 | try { |
| 392 | 392 | $dataArchive->attachFile($sspakFilepath, $dataTransfer); |
| 393 | 393 | $dataArchive->setArchiveFromFiles($filepathBase); |
| 394 | - } catch(Exception $e) { |
|
| 394 | + } catch (Exception $e) { |
|
| 395 | 395 | $log->write($e->getMessage()); |
| 396 | 396 | throw new RuntimeException($e->getMessage()); |
| 397 | 397 | } |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $process = new AbortableProcess(sprintf('rm -rf %s/assets && rm -f %s', escapeshellarg($filepathBase), escapeshellarg($databasePath))); |
| 403 | 403 | $process->setTimeout(120); |
| 404 | 404 | $process->run(); |
| 405 | - if(!$process->isSuccessful()) { |
|
| 405 | + if (!$process->isSuccessful()) { |
|
| 406 | 406 | $log->write('Could not delete temporary files'); |
| 407 | 407 | throw new RuntimeException($process->getErrorOutput()); |
| 408 | 408 | } |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | $command->run(function($type, $buffer) use($log) { |
| 422 | 422 | $log->write($buffer); |
| 423 | 423 | }); |
| 424 | - if(!$command->isSuccessful()) { |
|
| 424 | + if (!$command->isSuccessful()) { |
|
| 425 | 425 | $log->write(sprintf('Rebuild of "%s" failed: %s', $name, $command->getErrorOutput())); |
| 426 | 426 | throw new RuntimeException($command->getErrorOutput()); |
| 427 | 427 | } |
@@ -451,14 +451,14 @@ discard block |
||
| 451 | 451 | }; |
| 452 | 452 | |
| 453 | 453 | // Restore database into target environment |
| 454 | - if(in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 454 | + if (in_array($dataTransfer->Mode, array('all', 'db'))) { |
|
| 455 | 455 | $log->write(sprintf('Restore of database to "%s" started', $name)); |
| 456 | - $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'database.sql'); |
|
| 456 | + $args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'database.sql'); |
|
| 457 | 457 | $command = $this->getCommand('data:pushdb', 'db', $environment, $args, $log); |
| 458 | 458 | $command->run(function($type, $buffer) use($log) { |
| 459 | 459 | $log->write($buffer); |
| 460 | 460 | }); |
| 461 | - if(!$command->isSuccessful()) { |
|
| 461 | + if (!$command->isSuccessful()) { |
|
| 462 | 462 | $cleanupFn(); |
| 463 | 463 | $log->write(sprintf('Restore of database to "%s" failed: %s', $name, $command->getErrorOutput())); |
| 464 | 464 | $this->extend('dataTransferFailure', $environment, $log); |
@@ -468,14 +468,14 @@ discard block |
||
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | // Restore assets into target environment |
| 471 | - if(in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 471 | + if (in_array($dataTransfer->Mode, array('all', 'assets'))) { |
|
| 472 | 472 | $log->write(sprintf('Restore of assets to "%s" started', $name)); |
| 473 | - $args = array('data_path' => $workingDir . DIRECTORY_SEPARATOR . 'assets'); |
|
| 473 | + $args = array('data_path' => $workingDir.DIRECTORY_SEPARATOR.'assets'); |
|
| 474 | 474 | $command = $this->getCommand('data:pushassets', 'web', $environment, $args, $log); |
| 475 | 475 | $command->run(function($type, $buffer) use($log) { |
| 476 | 476 | $log->write($buffer); |
| 477 | 477 | }); |
| 478 | - if(!$command->isSuccessful()) { |
|
| 478 | + if (!$command->isSuccessful()) { |
|
| 479 | 479 | $cleanupFn(); |
| 480 | 480 | $log->write(sprintf('Restore of assets to "%s" failed: %s', $name, $command->getErrorOutput())); |
| 481 | 481 | $this->extend('dataTransferFailure', $environment, $log); |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | $timeout = 600; |
| 501 | 501 | $tick = 60; |
| 502 | 502 | |
| 503 | - if(!$url) { |
|
| 503 | + if (!$url) { |
|
| 504 | 504 | $log->write('Skipping site accessible check: no URL found.'); |
| 505 | 505 | return true; |
| 506 | 506 | } |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | // query the site every second. Note that if the URL doesn't respond, |
| 532 | 532 | // curl_exec will take 5 seconds to timeout (see CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT above) |
| 533 | 533 | do { |
| 534 | - if(time() > $start + $timeout) { |
|
| 534 | + if (time() > $start + $timeout) { |
|
| 535 | 535 | $log->write(sprintf(' * Failed: check for %s timed out after %smin', $url, $timeout / 60)); |
| 536 | 536 | return false; |
| 537 | 537 | } |
@@ -540,13 +540,13 @@ discard block |
||
| 540 | 540 | |
| 541 | 541 | // check the HTTP response code for HTTP protocols |
| 542 | 542 | $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 543 | - if($status && !in_array($status, [500, 501, 502, 503, 504])) { |
|
| 543 | + if ($status && !in_array($status, [500, 501, 502, 503, 504])) { |
|
| 544 | 544 | $success = true; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | // check for any curl errors, mostly for checking the response state of non-HTTP protocols, |
| 548 | 548 | // but applies to checks of any protocol |
| 549 | - if($response && !curl_errno($ch)) { |
|
| 549 | + if ($response && !curl_errno($ch)) { |
|
| 550 | 550 | $success = true; |
| 551 | 551 | } |
| 552 | 552 | |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | sleep(1); |
| 577 | - } while(!$success); |
|
| 577 | + } while (!$success); |
|
| 578 | 578 | |
| 579 | 579 | curl_close($ch); |
| 580 | 580 | $log->write(' * Success: site is accessible!'); |