Completed
Pull Request — master (#489)
by Helpful
03:51
created
code/model/jobs/DNDeployment.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
         $status = new Resque_Job_Status($this->ResqueToken);
119 119
         $statusCode = $status->get();
120 120
         // The Resque job can no longer be found, fallback to the DNDeployment.Status
121
-        if ($statusCode === false) {
121
+        if($statusCode === false) {
122 122
             // Translate from the DNDeployment.Status to the Resque job status for UI purposes
123
-            switch ($this->Status) {
123
+            switch($this->Status) {
124 124
                 case 'Finished':
125 125
                     return 'Complete';
126 126
                 case 'Started':
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public function getRepository()
142 142
     {
143
-        if (!$this->SHA) {
143
+        if(!$this->SHA) {
144 144
             return null;
145 145
         }
146 146
         return $this->Environment()->Project()->getRepository();
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
     public function getCommit()
156 156
     {
157 157
         $repo = $this->getRepository();
158
-        if ($repo) {
158
+        if($repo) {
159 159
             try {
160 160
                 return $repo->getCommit($this->SHA);
161
-            } catch (Gitonomy\Git\Exception\ReferenceNotFoundException $ex) {
161
+            } catch(Gitonomy\Git\Exception\ReferenceNotFoundException $ex) {
162 162
                 return null;
163 163
             }
164 164
         }
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
     public function getCommitMessage()
176 176
     {
177 177
         $commit = $this->getCommit();
178
-        if ($commit) {
178
+        if($commit) {
179 179
             try {
180 180
                 return Convert::raw2xml($commit->getMessage());
181
-            } catch (Gitonomy\Git\Exception\ReferenceNotFoundException $e) {
181
+            } catch(Gitonomy\Git\Exception\ReferenceNotFoundException $e) {
182 182
                 return null;
183 183
             }
184 184
         }
@@ -194,10 +194,10 @@  discard block
 block discarded – undo
194 194
     {
195 195
         $returnTags = array();
196 196
         $repo = $this->getRepository();
197
-        if ($repo) {
197
+        if($repo) {
198 198
             $tags = $repo->getReferences()->resolveTags($this->SHA);
199
-            if (!empty($tags)) {
200
-                foreach ($tags as $tag) {
199
+            if(!empty($tags)) {
200
+                foreach($tags as $tag) {
201 201
                     $field = Varchar::create('Tag', '255');
202 202
                     $field->setValue($tag->getName());
203 203
                     $returnTags[] = $field;
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
     public function getFullDeployMessages()
217 217
     {
218 218
         $strategy = $this->getDeploymentStrategy();
219
-        if ($strategy->getActionCode()!=='full') {
219
+        if($strategy->getActionCode() !== 'full') {
220 220
             return null;
221 221
         }
222 222
 
223 223
         $changes = $strategy->getChangesModificationNeeded();
224 224
         $messages = [];
225
-        foreach ($changes as $change => $details) {
226
-            if ($change==='Code version') {
225
+        foreach($changes as $change => $details) {
226
+            if($change === 'Code version') {
227 227
                 continue;
228 228
             }
229 229
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
             ];
237 237
         }
238 238
 
239
-        if (empty($messages)) {
239
+        if(empty($messages)) {
240 240
             $messages[] = [
241 241
                 'Flag' => '',
242 242
                 'Text' => '<i>Environment changes have been made.</i>'
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
     public function getTag()
255 255
     {
256 256
         $tags = $this->getTags();
257
-        if ($tags->count() > 0) {
257
+        if($tags->count() > 0) {
258 258
             return $tags->last();
259 259
         }
260 260
         return null;
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
     {
282 282
         $list = new ArrayList();
283 283
         $strategy = $this->getDeploymentStrategy();
284
-        foreach ($strategy->getChanges() as $name => $change) {
285
-            if (empty($change['to'])) {
284
+        foreach($strategy->getChanges() as $name => $change) {
285
+            if(empty($change['to'])) {
286 286
                 continue;
287 287
             }
288 288
 
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
         // Make sure we use the SHA as it was written into this DNDeployment.
326 326
         $args['sha'] = $this->SHA;
327 327
 
328
-        if (!$this->DeployerID) {
328
+        if(!$this->DeployerID) {
329 329
             $this->DeployerID = Member::currentUserID();
330 330
         }
331 331
 
332
-        if ($this->DeployerID) {
332
+        if($this->DeployerID) {
333 333
             $deployer = $this->Deployer();
334 334
             $message = sprintf(
335 335
                 'Deploy to %s initiated by %s (%s), with IP address %s',
Please login to merge, or discard this patch.
code/model/jobs/DNGitFetch.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
         $project = $this->Project();
58 58
         $log = $this->log();
59 59
 
60
-        if (!$this->DeployerID) {
60
+        if(!$this->DeployerID) {
61 61
             $this->DeployerID = Member::currentUserID();
62 62
         }
63 63
 
64
-        if ($this->DeployerID) {
64
+        if($this->DeployerID) {
65 65
             $deployer = $this->Deployer();
66 66
             $message = sprintf(
67 67
                 'Update repository job for %s initiated by %s (%s)',
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
         $status = new Resque_Job_Status($this->ResqueToken);
140 140
         $statusCode = $status->get();
141 141
         // The Resque job can no longer be found, fallback to the DNDeployment.Status
142
-        if ($statusCode === false) {
142
+        if($statusCode === false) {
143 143
             // Translate from the DNDeployment.Status to the Resque job status for UI purposes
144
-            switch ($this->Status) {
144
+            switch($this->Status) {
145 145
                 case 'Finished':
146 146
                     return 'Complete';
147 147
                 case 'Started':
Please login to merge, or discard this patch.
code/model/jobs/DNPing.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -115,11 +115,11 @@
 block discarded – undo
115 115
             'env' => $project->getProcessEnv()
116 116
         );
117 117
 
118
-        if (!$this->DeployerID) {
118
+        if(!$this->DeployerID) {
119 119
             $this->DeployerID = Member::currentUserID();
120 120
         }
121 121
 
122
-        if ($this->DeployerID) {
122
+        if($this->DeployerID) {
123 123
             $deployer = $this->Deployer();
124 124
             $message = sprintf(
125 125
                 'Ping to %s initiated by %s (%s)',
Please login to merge, or discard this patch.
code/model/steps/DeploymentPipelineStep.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
     {
39 39
         parent::start();
40 40
 
41
-        switch ($this->Status) {
41
+        switch($this->Status) {
42 42
             case 'Started':
43 43
                 // If we are doing a subtask, check which one to continue
44
-                switch ($this->Doing) {
44
+                switch($this->Doing) {
45 45
                     case 'Deployment':
46 46
                         return $this->continueDeploy();
47 47
                     case 'Snapshot':
@@ -74,20 +74,20 @@  discard block
 block discarded – undo
74 74
         // Check environment and SHA
75 75
         $pipeline = $this->Pipeline();
76 76
         $environment = $pipeline->Environment();
77
-        if (empty($environment) || !$environment->exists()) {
77
+        if(empty($environment) || !$environment->exists()) {
78 78
             $this->log("No available environment for {$this->Title}");
79 79
             $this->markFailed();
80 80
             return false;
81 81
         }
82 82
 
83
-        if (empty($pipeline->SHA)) {
83
+        if(empty($pipeline->SHA)) {
84 84
             $this->log("No available SHA for {$this->Title}");
85 85
             $this->markFailed();
86 86
             return false;
87 87
         }
88 88
 
89 89
         // Skip deployment for dry run
90
-        if ($this->Pipeline()->DryRun) {
90
+        if($this->Pipeline()->DryRun) {
91 91
             $this->log("[Skipped] Create DNDeployment for SHA " . $pipeline->SHA);
92 92
             $this->write();
93 93
             return true;
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
         $this->write();
126 126
 
127 127
         // Skip deployment for dry run
128
-        if ($this->Pipeline()->DryRun) {
128
+        if($this->Pipeline()->DryRun) {
129 129
             $this->log("[Skipped] Create DNDataTransfer backup");
130 130
             return true;
131 131
         }
132 132
 
133 133
         // Skip snapshot for environments with no build
134
-        if (!$this->Pipeline()->Environment()->CurrentBuild()) {
134
+        if(!$this->Pipeline()->Environment()->CurrentBuild()) {
135 135
             $this->log('[Skipped] No current build, skipping snapshot');
136 136
             return true;
137 137
         }
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
         $this->log("Checking status of {$this->Title}...");
162 162
 
163 163
         // Skip snapshot for dry run
164
-        if ($this->Pipeline()->DryRun) {
164
+        if($this->Pipeline()->DryRun) {
165 165
             $this->log("[Skipped] Checking progress of snapshot backup");
166 166
             return $this->startDeploy();
167 167
         }
168 168
 
169 169
         // Skip snapshot for environments with no build
170
-        if (!$this->Pipeline()->Environment()->CurrentBuild()) {
170
+        if(!$this->Pipeline()->Environment()->CurrentBuild()) {
171 171
             return $this->startDeploy();
172 172
         }
173 173
 
174 174
         // Get related snapshot
175 175
         $snapshot = $this->Pipeline()->PreviousSnapshot();
176
-        if (empty($snapshot) || !$snapshot->exists()) {
176
+        if(empty($snapshot) || !$snapshot->exists()) {
177 177
             $this->log("Missing snapshot for in-progress {$this->Title}");
178 178
             $this->markFailed();
179 179
             return false;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
         // Check finished state
183 183
         $status = $snapshot->ResqueStatus();
184
-        if ($this->checkResqueStatus($status)) {
184
+        if($this->checkResqueStatus($status)) {
185 185
             // After snapshot is done, switch to doing deployment
186 186
             return $this->startDeploy();
187 187
         }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
         $this->log("Checking status of {$this->Title}...");
198 198
 
199 199
         // Skip deployment for dry run
200
-        if ($this->Pipeline()->DryRun) {
200
+        if($this->Pipeline()->DryRun) {
201 201
             $this->log("[Skipped] Checking progress of deployment");
202 202
             $this->finish();
203 203
             return !$this->isFailed();
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
         // Get related deployment
207 207
         $deployment = $this->Pipeline()->CurrentDeployment();
208
-        if (empty($deployment) || !$deployment->exists()) {
208
+        if(empty($deployment) || !$deployment->exists()) {
209 209
             $this->log("Missing deployment for in-progress {$this->Title}");
210 210
             $this->markFailed();
211 211
             return false;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
         // Check finished state
215 215
         $status = $deployment->ResqueStatus();
216
-        if ($this->checkResqueStatus($status)) {
216
+        if($this->checkResqueStatus($status)) {
217 217
             $this->finish();
218 218
         }
219 219
         return !$this->isFailed();
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     protected function checkResqueStatus($status)
229 229
     {
230
-        switch ($status) {
230
+        switch($status) {
231 231
             case "Complete":
232 232
                 return true;
233 233
             case "Failed":
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
             default:
241 241
                 // For running or queued tasks ensure that we have not exceeded
242 242
                 // a reasonable time-elapsed to consider this job inactive
243
-                if ($this->isTimedOut()) {
243
+                if($this->isTimedOut()) {
244 244
                     $this->log("{$this->Title} took longer than {$this->MaxDuration} seconds to run and has timed out");
245 245
                     $this->markFailed();
246 246
                     return false;
Please login to merge, or discard this patch.
code/model/steps/EmergencyRollbackStep.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public function start()
48 48
     {
49 49
         // Just in case this step is being mistakenly restarted
50
-        if (!empty($this->RolledBack)) {
50
+        if(!empty($this->RolledBack)) {
51 51
             $this->log(_t('EmergencyRollbackStep.BEENROLLEDBACK',
52 52
                 "{$this->Title} has already been rolled back"));
53 53
             $this->markFailed();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         }
56 56
 
57 57
         // check if we have timed out
58
-        if ($this->isTimedOut()) {
58
+        if($this->isTimedOut()) {
59 59
             $this->log(sprintf(_t('EmergencyRollbackStep.ROLLBACKTIMEOUT',
60 60
                 "{$this->Title} is older than %s seconds and has timed out"),
61 61
                 $this->MaxDuration));
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         }
65 65
 
66 66
         // Begin or process this step
67
-        switch ($this->Status) {
67
+        switch($this->Status) {
68 68
             case 'Started':
69 69
                 return true;
70 70
             case 'Queued':
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     public function rollback()
97 97
     {
98 98
         // Check permission
99
-        if (!$this->canTriggerRollback()) {
99
+        if(!$this->canTriggerRollback()) {
100 100
             return Security::permissionFailure(
101 101
                 null,
102 102
                 _t("EmergencyRollbackStep.DENYROLLBACKED",
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             );
105 105
         }
106 106
 
107
-        if ($this->Status == 'Queued') {
107
+        if($this->Status == 'Queued') {
108 108
             $this->start();
109 109
         }
110 110
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $this->write();
116 116
 
117 117
         // Rollback itself is handled by the Pipeline object. This step will be marked as failed.
118
-        if ($this->Pipeline()->isRunning()) {
118
+        if($this->Pipeline()->isRunning()) {
119 119
             $this->Pipeline()->markFailed();
120 120
             return true;
121 121
         } else {
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     public function dismiss()
130 130
     {
131 131
         // Check permission
132
-        if (!$this->canTriggerRollback()) {
132
+        if(!$this->canTriggerRollback()) {
133 133
             return Security::permissionFailure(
134 134
                 null,
135 135
                 _t("EmergencyRollbackStep.DENYROLLBACKED",
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     public function beginRollbackWindow()
149 149
     {
150 150
         $this->Status = 'Started';
151
-        if (!$this->Started) {
151
+        if(!$this->Started) {
152 152
             $this->Started = SS_Datetime::now()->Rfc2822();
153 153
         }
154 154
         $this->log(_t('EmergencyRollbackStep.BEGINROLLBACKWINDOW',
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     public function getRunningDescription()
163 163
     {
164 164
         // Don't show options if this step has already been confirmed
165
-        if ($this->RolledBack) {
165
+        if($this->RolledBack) {
166 166
             return;
167 167
         }
168 168
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     public function allowedActions()
174 174
     {
175 175
         // Don't show options if this step has already been confirmed or can't be confirmed
176
-        if (!$this->canTriggerRollback()) {
176
+        if(!$this->canTriggerRollback()) {
177 177
             return parent::allowedActions();
178 178
         }
179 179
 
Please login to merge, or discard this patch.
code/model/steps/LongRunningPipelineStep.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function getAge()
50 50
     {
51
-        if ($this->Started) {
51
+        if($this->Started) {
52 52
             $started = intval($this->dbObject('Started')->Format('U'));
53 53
             $now = intval(SS_Datetime::now()->Format('U'));
54
-            if ($started && $now) {
54
+            if($started && $now) {
55 55
                 return $now - $started;
56 56
             }
57 57
         }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public function start()
62 62
     {
63 63
         // Ensure started date is set
64
-        if (!$this->Started) {
64
+        if(!$this->Started) {
65 65
             $this->Started = SS_Datetime::now()->Rfc2822();
66 66
             $this->write();
67 67
         }
Please login to merge, or discard this patch.
code/model/steps/PipelineStep.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         $niceName = $this->getConfigSetting('NiceName')
86 86
             ?: ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $this->getTitle()))));
87 87
 
88
-        if ($this->isFinished()) {
88
+        if($this->isFinished()) {
89 89
             $niceName = $this->getConfigSetting('NiceDone') ?: $niceName;
90 90
         }
91 91
 
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function getConfigData()
104 104
     {
105
-        if (!$this->Config) {
105
+        if(!$this->Config) {
106 106
             return array();
107 107
         }
108 108
 
109 109
         // Merge with defaults
110
-        if (!$this->mergedConfig) {
110
+        if(!$this->mergedConfig) {
111 111
             $this->mergedConfig = unserialize($this->Config);
112
-            if ($default = self::config()->default_config) {
112
+            if($default = self::config()->default_config) {
113 113
                 Config::merge_array_low_into_high($this->mergedConfig, $default);
114 114
             }
115 115
         }
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
     public function getConfigSetting($setting)
142 142
     {
143 143
         $source = $this->getConfigData();
144
-        foreach (func_get_args() as $setting) {
145
-            if (empty($source[$setting])) {
144
+        foreach(func_get_args() as $setting) {
145
+            if(empty($source[$setting])) {
146 146
                 return null;
147 147
             }
148 148
             $source = $source[$setting];
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
      */
243 243
     protected function getDependentEnvironment()
244 244
     {
245
-        if ($this->getConfigSetting('PerformTestOn') === 'DependentEnvironment') {
245
+        if($this->getConfigSetting('PerformTestOn') === 'DependentEnvironment') {
246 246
             try {
247 247
                 $environment = $this->Pipeline()->getDependentEnvironment();
248
-            } catch (Exception $e) {
248
+            } catch(Exception $e) {
249 249
                 $this->log($e->getMessage());
250 250
                 $this->markFailed();
251 251
                 return false;
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      */
281 281
     public function abort()
282 282
     {
283
-        if ($this->isQueued() || $this->isRunning()) {
283
+        if($this->isQueued() || $this->isRunning()) {
284 284
             $this->Status = 'Aborted';
285 285
             $this->log('Step aborted');
286 286
             $this->write();
Please login to merge, or discard this patch.
code/model/steps/RollbackStep.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
     {
57 57
         parent::start();
58 58
 
59
-        switch ($this->Status) {
59
+        switch($this->Status) {
60 60
             case 'Started':
61 61
                 // If we are doing a subtask, check which one to continue
62
-                switch ($this->Doing) {
62
+                switch($this->Doing) {
63 63
                     case 'Deployment':
64 64
                         return $this->continueRevertDeploy();
65 65
                     case 'Snapshot':
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         $this->log("{$this->Title} starting revert deployment");
92 92
 
93 93
         // Skip deployment for dry run
94
-        if ($this->Pipeline()->DryRun) {
94
+        if($this->Pipeline()->DryRun) {
95 95
             $this->log("[Skipped] Create DNDeployment");
96 96
             $this->write();
97 97
             return true;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         // Get old deployment from pipeline
101 101
         $pipeline = $this->Pipeline();
102 102
         $previous = $pipeline->PreviousDeployment();
103
-        if (empty($previous) || empty($previous->SHA)) {
103
+        if(empty($previous) || empty($previous->SHA)) {
104 104
             $this->log("No available SHA for {$this->Title}");
105 105
             $this->markFailed();
106 106
             return false;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         $this->log("{$this->Title} reverting database from snapshot");
137 137
 
138 138
         // Skip deployment for dry run
139
-        if ($this->Pipeline()->DryRun) {
139
+        if($this->Pipeline()->DryRun) {
140 140
             $this->write();
141 141
             $this->log("[Skipped] Create DNDataTransfer restore");
142 142
             return true;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         // Get snapshot
146 146
         $pipeline = $this->Pipeline();
147 147
         $backup = $pipeline->PreviousSnapshot();
148
-        if (empty($backup) || !$backup->exists()) {
148
+        if(empty($backup) || !$backup->exists()) {
149 149
             $this->log("No database to revert for {$this->Title}");
150 150
             $this->markFailed();
151 151
             return false;
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
         $this->log("Checking status of {$this->Title}...");
177 177
 
178 178
         // Skip snapshot for dry run
179
-        if ($this->Pipeline()->DryRun) {
179
+        if($this->Pipeline()->DryRun) {
180 180
             $this->log("[Skipped] Checking progress of snapshot restore");
181 181
             return $this->finish();
182 182
         }
183 183
 
184 184
         // Get related snapshot
185 185
         $transfer = $this->RollbackDatabase();
186
-        if (empty($transfer) || !$transfer->exists()) {
186
+        if(empty($transfer) || !$transfer->exists()) {
187 187
             $this->log("Missing database transfer for in-progress {$this->Title}");
188 188
             $this->markFailed();
189 189
             return false;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
         // Check finished state
193 193
         $status = $transfer->ResqueStatus();
194
-        if ($this->checkResqueStatus($status)) {
194
+        if($this->checkResqueStatus($status)) {
195 195
             // Re-enable the site by disabling the maintenance, since the DB restored successfully
196 196
             $this->Pipeline()->Environment()->disableMaintenance($this->Pipeline()->getLogger());
197 197
 
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
         $this->log("Checking status of {$this->Title}...");
211 211
 
212 212
         // Skip deployment for dry run
213
-        if ($this->Pipeline()->DryRun) {
213
+        if($this->Pipeline()->DryRun) {
214 214
             $this->log("[Skipped] Checking progress of deployment");
215
-            if ($this->getConfigSetting('RestoreDB')) {
215
+            if($this->getConfigSetting('RestoreDB')) {
216 216
                 return $this->startRevertDatabase();
217 217
             } else {
218 218
                 $this->finish();
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 
223 223
         // Get related deployment
224 224
         $deployment = $this->RollbackDeployment();
225
-        if (empty($deployment) || !$deployment->exists()) {
225
+        if(empty($deployment) || !$deployment->exists()) {
226 226
             $this->log("Missing deployment for in-progress {$this->Title}");
227 227
             $this->markFailed();
228 228
             return false;
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 
231 231
         // Check finished state
232 232
         $status = $deployment->ResqueStatus();
233
-        if ($this->checkResqueStatus($status)) {
233
+        if($this->checkResqueStatus($status)) {
234 234
             // Since deployment is finished, check if we should also do a db restoration
235
-            if ($this->doRestoreDB()) {
235
+            if($this->doRestoreDB()) {
236 236
                 return $this->startRevertDatabase();
237 237
             } else {
238 238
                 $this->finish();
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      */
260 260
     protected function checkResqueStatus($status)
261 261
     {
262
-        switch ($status) {
262
+        switch($status) {
263 263
             case "Complete":
264 264
                 return true;
265 265
             case "Failed":
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             default:
273 273
                 // For running or queued tasks ensure that we have not exceeded
274 274
                 // a reasonable time-elapsed to consider this job inactive
275
-                if ($this->isTimedOut()) {
275
+                if($this->isTimedOut()) {
276 276
                     $this->log("{$this->Title} took longer than {$this->MaxDuration} seconds to run and has timed out");
277 277
                     $this->markFailed();
278 278
                     return false;
Please login to merge, or discard this patch.
code/model/steps/SmokeTestPipelineStep.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 
72 72
         // Merge with default tests
73 73
         $defaultTests = $this->Pipeline()->getConfigSetting('PipelineConfig', 'Tests');
74
-        if ($tests && $defaultTests) {
74
+        if($tests && $defaultTests) {
75 75
             Config::merge_array_low_into_high($tests, $defaultTests);
76
-        } elseif (!$tests && $defaultTests) {
76
+        } elseif(!$tests && $defaultTests) {
77 77
             $tests = $defaultTests;
78 78
         }
79
-        if ($tests) {
79
+        if($tests) {
80 80
             return $tests;
81 81
         }
82 82
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         // site's homepage by looking at the DNEnvironment fields.
85 85
         $environment = $this->getDependentEnvironment();
86 86
         $url = $environment->URL;
87
-        if ($url) {
87
+        if($url) {
88 88
             return array(
89 89
                 'default' => array(
90 90
                     'URL' => $url,
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         // don't allow this to run for more than 10 seconds to avoid tying up webserver processes.
111 111
 
112 112
         // if we need to use a proxy, ensure that is configured
113
-        if (defined('SS_OUTBOUND_PROXY')) {
113
+        if(defined('SS_OUTBOUND_PROXY')) {
114 114
             curl_setopt($handle, CURLOPT_PROXY, SS_OUTBOUND_PROXY);
115 115
             curl_setopt($handle, CURLOPT_PROXYPORT, SS_OUTBOUND_PROXY_PORT);
116 116
         }
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
         curl_setopt($ch, CURLOPT_URL, $test['URL']);
132 132
 
133 133
         // Allow individual tests to override number of attempts
134
-        $attempts = (int) $this->getConfigSetting('Attempts');
135
-        if (!empty($test['Attempts'])) {
134
+        $attempts = (int)$this->getConfigSetting('Attempts');
135
+        if(!empty($test['Attempts'])) {
136 136
             $attempts = $test['Attempts'];
137 137
         }
138 138
 
139 139
         // Run through each attempt
140
-        for ($i = 0; $i < $attempts; $i++) {
141
-            if ($i > 0) {
140
+        for($i = 0; $i < $attempts; $i++) {
141
+            if($i > 0) {
142 142
                 $this->log("Request failed, performing reattempt (#{$i})");
143 143
 
144 144
                 // Ensure a non-zero delay between each request
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
             // Perform request
150 150
             $contents = curl_exec($ch);
151
-            if (curl_errno($ch)) {
151
+            if(curl_errno($ch)) {
152 152
                 $this->log(sprintf('Curl error: %s', curl_error($ch)));
153 153
                 continue;
154 154
             }
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
             $info = curl_getinfo($ch);
158 158
 
159 159
             // if an expected response time is specified, check that against the results
160
-            if (isset($test['ExpectResponse'])) {
161
-                if ($info['total_time'] > $test['ExpectResponse']) {
160
+            if(isset($test['ExpectResponse'])) {
161
+                if($info['total_time'] > $test['ExpectResponse']) {
162 162
                     $this->log(sprintf(
163 163
                         'Smoke test "%s" to URL %s failed. Expected response time %s seconds, actual was %s seconds',
164 164
                         $name,
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             }
172 172
 
173 173
             // Check response code
174
-            if ($info['http_code'] != $test['ExpectStatus']) {
174
+            if($info['http_code'] != $test['ExpectStatus']) {
175 175
                 $this->log("=================================================================");
176 176
                 $this->log(sprintf(
177 177
                     "Printing output from smoke test '%s' (URL: '%s'):",
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
         }
198 198
 
199 199
         // Run out of re-attempts
200
-        if ($attempts > 1) {
200
+        if($attempts > 1) {
201 201
             $this->log("Failed after {$attempts} attempts");
202 202
         }
203 203
         return false;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
         // Get tests to run
213 213
         $tests = $this->getTests();
214
-        if (empty($tests)) {
214
+        if(empty($tests)) {
215 215
             $this->log('No smoke tests available. Aborting');
216 216
             $this->markFailed();
217 217
             return false;
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
         // work through each of the configured tests and perform a web request and check the result
221 221
         $ch = $this->initCurl();
222 222
         $success = true;
223
-        foreach ($tests as $name => $test) {
223
+        foreach($tests as $name => $test) {
224 224
             $testSuccess = $this->runTest($ch, $name, $test);
225 225
             $success = $testSuccess && $success;
226 226
         }
227 227
         curl_close($ch);
228 228
 
229 229
         // Check result
230
-        if ($success) {
230
+        if($success) {
231 231
             $this->finish();
232 232
         } else {
233 233
             // At least one test failed, so mark the test as failed
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
     public function markFailed($notify = true)
240 240
     {
241
-        if ($this->getDryRun()) {
241
+        if($this->getDryRun()) {
242 242
             $this->log("[Skipped] Smoke testing failed: Putting up emergency maintenance page");
243 243
         } else {
244 244
             // Put up maintenance page after this fails
Please login to merge, or discard this patch.