Completed
Push — master ( 6ac78c...9f2555 )
by Stig
05:01 queued 59s
created
code/model/DNData.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		parent::__construct();
60 60
 
61 61
 		// Better to use injector to set these
62
-		if(func_num_args() == 0) {
62
+		if (func_num_args() == 0) {
63 63
 			return;
64 64
 		}
65 65
 		Deprecation::notice(
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 * @param string $environmentDir
89 89
 	 */
90 90
 	public function setEnvironmentDir($environmentDir) {
91
-		if($environmentDir[0] != "/") {
92
-			$environmentDir = BASE_PATH . '/' . $environmentDir;
91
+		if ($environmentDir[0] != "/") {
92
+			$environmentDir = BASE_PATH.'/'.$environmentDir;
93 93
 		}
94 94
 		$this->environmentDir = realpath($environmentDir) ?: $environmentDir;
95 95
 	}
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param string $keyDir
110 110
 	 */
111 111
 	public function setKeyDir($keyDir) {
112
-		if($keyDir[0] != "/") {
113
-			$keyDir = BASE_PATH . '/' . $keyDir;
112
+		if ($keyDir[0] != "/") {
113
+			$keyDir = BASE_PATH.'/'.$keyDir;
114 114
 		}
115 115
 		$this->keyDir = realpath($keyDir) ?: $keyDir;
116 116
 	}
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 * @param string $signalDir
127 127
 	 */
128 128
 	public function setSignalDir($signalDir) {
129
-		if($signalDir[0] != "/") {
130
-			$signalDir = BASE_PATH . '/' . $signalDir;
129
+		if ($signalDir[0] != "/") {
130
+			$signalDir = BASE_PATH.'/'.$signalDir;
131 131
 		}
132 132
 		$this->signalDir = realpath($signalDir) ?: $signalDir;
133 133
 	}
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 	 * @param string $transferDir
169 169
 	 */
170 170
 	public function setDataTransferDir($transferDir) {
171
-		if($transferDir[0] != "/") {
172
-			$transferDir = BASE_PATH . '/' . $transferDir;
171
+		if ($transferDir[0] != "/") {
172
+			$transferDir = BASE_PATH.'/'.$transferDir;
173 173
 		}
174
-		if(strpos($transferDir, ASSETS_PATH) === false) {
174
+		if (strpos($transferDir, ASSETS_PATH) === false) {
175 175
 			throw new LogicException(sprintf(
176 176
 				'DNData::dataTransferDir needs to be located within <webroot>assets/ (location: %s)',
177 177
 				$transferDir
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function getProjectPaths() {
200 200
 		$paths = array();
201
-		if(!file_exists($this->getEnvironmentDir())) {
202
-			$eMessage = 'The environment directory ' . $this->getEnvironmentDir() . ' doesn\'t exist. Create it '
201
+		if (!file_exists($this->getEnvironmentDir())) {
202
+			$eMessage = 'The environment directory '.$this->getEnvironmentDir().' doesn\'t exist. Create it '
203 203
 			. 'first and add some projects to it.';
204 204
 			throw new Exception($eMessage);
205 205
 		}
206
-		foreach(scandir($this->getEnvironmentDir()) as $project) {
206
+		foreach (scandir($this->getEnvironmentDir()) as $project) {
207 207
 			// Exlcude dot-prefixed directories (.git was getting in the way)
208
-			if(preg_match('/^[^\.]/', $project)) {
209
-				$path = $this->getEnvironmentDir() . '/' . $project;
210
-				if(is_dir($path) && $project != '.' && $project != '..') {
208
+			if (preg_match('/^[^\.]/', $project)) {
209
+				$path = $this->getEnvironmentDir().'/'.$project;
210
+				if (is_dir($path) && $project != '.' && $project != '..') {
211 211
 					$paths[] = $project;
212 212
 				}
213 213
 			}
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
 	 * Returns an array of paths
222 222
 	 */
223 223
 	public function getEnvironmentPaths($project) {
224
-		$baseDir = $this->getEnvironmentDir() . '/' . $project;
224
+		$baseDir = $this->getEnvironmentDir().'/'.$project;
225 225
 
226 226
 		$paths = array();
227
-		if(!file_exists($baseDir)) {
228
-			throw new Exception('Environment directory ' . $baseDir . ' doesn\'t exist. Create it first.');
227
+		if (!file_exists($baseDir)) {
228
+			throw new Exception('Environment directory '.$baseDir.' doesn\'t exist. Create it first.');
229 229
 		}
230 230
 		// Search the directory for config files.
231
-		foreach(scandir($baseDir) as $environmentFile) {
232
-			if(preg_match('/\.rb$/', $environmentFile)) {
231
+		foreach (scandir($baseDir) as $environmentFile) {
232
+			if (preg_match('/\.rb$/', $environmentFile)) {
233 233
 				// Config found, wrap it into an object.
234 234
 				$paths[] = "$baseDir/$environmentFile";
235 235
 			}
Please login to merge, or discard this patch.
code/model/DNCommit.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @return string
75 75
 	 */
76 76
 	public function Name() {
77
-		if($this->name == null) {
77
+		if ($this->name == null) {
78 78
 			$this->name = $this->commit->getFixedShortHash(8);
79 79
 		}
80 80
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @return string
95 95
 	 */
96 96
 	public function SubjectMessage() {
97
-		if($this->subjectMessage == null) {
97
+		if ($this->subjectMessage == null) {
98 98
 			$this->subjectMessage = $this->commit->getSubjectMessage();
99 99
 		}
100 100
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	}
103 103
 
104 104
 	public function BodyMessage() {
105
-		if($this->bodyMessage == null) {
105
+		if ($this->bodyMessage == null) {
106 106
 			$this->bodyMessage = $this->commit->getBodyMessage();
107 107
 		}
108 108
 
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
 	 * @return ArrayList
114 114
 	 */
115 115
 	public function References() {
116
-		if($this->references !== null) {
116
+		if ($this->references !== null) {
117 117
 			return $this->references;
118 118
 		}
119 119
 		$this->references = new ArrayList();
120 120
 
121 121
 		// Add tags
122
-		foreach($this->commit->resolveReferences() as $reference) {
123
-			if($reference instanceof \Gitonomy\Git\Reference\Tag) {
122
+		foreach ($this->commit->resolveReferences() as $reference) {
123
+			if ($reference instanceof \Gitonomy\Git\Reference\Tag) {
124 124
 				$this->references->push(new ArrayData(array(
125 125
 					'Name' => $reference->getName(),
126 126
 					'Type' => 'Tag',
@@ -151,16 +151,16 @@  discard block
 block discarded – undo
151 151
 	public function CurrentlyDeployedTo() {
152 152
 		$environments = $this->project->Environments();
153 153
 		$envList = new ArrayList();
154
-		foreach($environments as $environment) {
154
+		foreach ($environments as $environment) {
155 155
 			$deployments = DNDeployment::get()
156 156
 				->filter('State', 'Completed')
157 157
 				->filter('EnvironmentID', $environment->ID)
158 158
 				->sort('LastEdited DESC');
159
-			if(!$deployments->count()) {
159
+			if (!$deployments->count()) {
160 160
 				continue;
161 161
 			}
162 162
 			$latest = $deployments->first();
163
-			if($latest->SHA === $this->commit->getHash()) {
163
+			if ($latest->SHA === $this->commit->getHash()) {
164 164
 				$envList->push($environment);
165 165
 			}
166 166
 		}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	public function EverDeployedTo($environmentName) {
175 175
 		$environments = $this->project->Environments()->filter('Name', $environmentName);
176
-		if(!$environments->count()) {
176
+		if (!$environments->count()) {
177 177
 			return false;
178 178
 		}
179 179
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 				->filter('State', 'Completed')
184 184
 				->filter('EnvironmentID', $environment->ID);
185 185
 
186
-		if($deployments->count()) {
186
+		if ($deployments->count()) {
187 187
 			return true;
188 188
 		}
189 189
 
Please login to merge, or discard this patch.
code/model/DNReferenceList.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -100,24 +100,24 @@  discard block
 block discarded – undo
100 100
 	protected function getReferences() {
101 101
 		try {
102 102
 			$repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath());
103
-		} catch(Exception $e) {
103
+		} catch (Exception $e) {
104 104
 			return array();
105 105
 		}
106 106
 
107
-		if($this->getTags) {
108
-			if($this->reference) {
107
+		if ($this->getTags) {
108
+			if ($this->reference) {
109 109
 				throw new LogicException("Can't have \$reference and \$getTags both set");
110 110
 			}
111 111
 			$log = $repository->getReferences()->getTags();
112 112
 
113
-		} else if($this->reference) {
113
+		} else if ($this->reference) {
114 114
 			$log = $this->reference->getLog();
115 115
 		} else {
116 116
 			$log = $repository->getLog();
117 117
 		}
118 118
 
119
-		if($this->limit) {
120
-			if(is_array($log)) {
119
+		if ($this->limit) {
120
+			if (is_array($log)) {
121 121
 				$limitedLog = array_slice($log, 0, $this->limit);
122 122
 			} else {
123 123
 				$limitedLog = $log->setLimit($this->limit);
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
 
129 129
 		// cache them for look up in byName
130 130
 		$builds = array();
131
-		foreach($limitedLog as $reference) {
132
-			if(!empty($this->blockBranch)) {
131
+		foreach ($limitedLog as $reference) {
132
+			if (!empty($this->blockBranch)) {
133 133
 				$branchesIncluding = GitonomyCache::getIncludingBranches($reference);
134
-				foreach($branchesIncluding as $candidate) {
135
-					if($candidate->getName() == $this->blockBranch) {
134
+				foreach ($branchesIncluding as $candidate) {
135
+					if ($candidate->getName() == $this->blockBranch) {
136 136
 						// Break out of the function
137 137
 						return $builds;
138 138
 					}
139 139
 				}
140 140
 			}
141 141
 
142
-			if($this->getTags) {
142
+			if ($this->getTags) {
143 143
 				$builds[] = DNTag::create($reference, $this->project, $this->data);
144 144
 			} else {
145 145
 				$name = $this->reference ? $this->reference->getName() : '';
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @return DNCommit
158 158
 	 */
159 159
 	public function byName($hash) {
160
-		if($this->loaded === false) {
160
+		if ($this->loaded === false) {
161 161
 			$this->items = $this->getReferences();
162 162
 			$this->loaded = true;
163 163
 		}
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
 		// The item might not be in the list because of the limit, try to find
166 166
 		// in an older version and add it to the list.
167 167
 		$found = null;
168
-		foreach($this->items as $item) {
169
-			if($item->SHA() == $hash) {
168
+		foreach ($this->items as $item) {
169
+			if ($item->SHA() == $hash) {
170 170
 				$found = $item;
171 171
 				break;
172 172
 			}
173 173
 		}
174 174
 
175
-		if($found === null) {
175
+		if ($found === null) {
176 176
 			$repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath());
177 177
 			$commit = new Gitonomy\Git\Commit($repository, $hash);
178 178
 			$found = DNCommit::create($commit, $this->project, $this->data);
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 	 * @return ArrayIterator
194 194
 	 */
195 195
 	public function getIterator() {
196
-		if($this->loaded === false) {
196
+		if ($this->loaded === false) {
197 197
 			$this->items = $this->getReferences();
198 198
 			$this->loaded = true;
199 199
 		}
200
-		foreach($this->items as $item) {
201
-			if(is_array($item)) {
200
+		foreach ($this->items as $item) {
201
+			if (is_array($item)) {
202 202
 				$this->items[] = new ArrayData($item);
203 203
 			}
204 204
 		}
Please login to merge, or discard this patch.
code/jobs/DataTransferJob.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 	}
21 21
 
22 22
 	public function perform() {
23
-		echo "[-] DataTransferJob starting" . PHP_EOL;
23
+		echo "[-] DataTransferJob starting".PHP_EOL;
24 24
 		$log = new DeploynautLogFile($this->args['logfile']);
25 25
 		$dataTransfer = DNDataTransfer::get()->byID($this->args['dataTransferID']);
26 26
 		$environment = $dataTransfer->Environment();
27 27
 		$backupDataTransfer = null;
28 28
 
29
-		if(
29
+		if (
30 30
 			!empty($this->args['backupBeforePush'])
31 31
 			&& $this->args['backupBeforePush'] !== 'false'
32 32
 			&& $dataTransfer->Direction == 'push'
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 					'Created:GreaterThan' => strtotime('-30 minutes')
55 55
 				))
56 56
 				->exclude('ID', $dataTransfer->ID);
57
-			if($runningTransfers->count()) {
57
+			if ($runningTransfers->count()) {
58 58
 				$runningTransfer = $runningTransfers->first();
59 59
 				$message = sprintf(
60 60
 					'Error: another transfer is in progress (started at %s by %s)',
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 
68 68
 			$this->performBackup($backupDataTransfer, $log);
69 69
 			$environment->Backend()->dataTransfer($dataTransfer, $log);
70
-		} catch(Exception $e) {
71
-			echo "[-] DataTransferJob failed" . PHP_EOL;
70
+		} catch (Exception $e) {
71
+			echo "[-] DataTransferJob failed".PHP_EOL;
72 72
 			throw $e;
73 73
 		}
74 74
 
75 75
 		$this->updateStatus('Finished');
76
-		echo "[-] DataTransferJob finished" . PHP_EOL;
76
+		echo "[-] DataTransferJob finished".PHP_EOL;
77 77
 	}
78 78
 
79 79
 	protected function performBackup($backupDataTransfer, DeploynautLogFile $log) {
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			DB::connect($databaseConfig);
89 89
 			$backupDataTransfer->Status = 'Finished';
90 90
 			$backupDataTransfer->write();
91
-		} catch(Exception $e) {
91
+		} catch (Exception $e) {
92 92
 			global $databaseConfig;
93 93
 			DB::connect($databaseConfig);
94 94
 			$backupDataTransfer->Status = 'Failed';
Please login to merge, or discard this patch.
code/jobs/FetchJob.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	public function perform() {
34 34
 		set_time_limit(0);
35 35
 
36
-		if(!empty($this->args['logfile'])) {
36
+		if (!empty($this->args['logfile'])) {
37 37
 			$this->log = new DeploynautLogFile($this->args['logfile']);
38 38
 		}
39 39
 
40 40
 		$this->project = DNProject::get()->byId($this->args['projectID']);
41
-		if(!($this->project && $this->project->exists())) {
41
+		if (!($this->project && $this->project->exists())) {
42 42
 			throw new RuntimeException(sprintf('Project ID %s not found', $this->args['projectID']));
43 43
 		}
44 44
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		// Disallow concurrent git fetches on the same project.
48 48
 		// Only consider fetches started in the last 30 minutes (older jobs probably got stuck)
49 49
 		try {
50
-			if(!empty($this->args['fetchID'])) {
50
+			if (!empty($this->args['fetchID'])) {
51 51
 				$runningFetches = DNGitFetch::get()
52 52
 					->filter(array(
53 53
 						'ProjectID' => $this->project->ID,
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 					))
57 57
 					->exclude('ID', $this->args['fetchID']);
58 58
 
59
-				if($runningFetches->count()) {
59
+				if ($runningFetches->count()) {
60 60
 					$runningFetch = $runningFetches->first();
61 61
 					$message = sprintf(
62 62
 						'Another fetch is in progress (started at %s by %s)',
63 63
 						$runningFetch->dbObject('Created')->Nice(),
64 64
 						$runningFetch->Deployer()->Title
65 65
 					);
66
-					if($this->log) {
66
+					if ($this->log) {
67 67
 						$this->log->write($message);
68 68
 					}
69 69
 					throw new RuntimeException($message);
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 
73 73
 			// Decide whether we need to just update what we already have
74 74
 			// or initiate a clone if no local repo exists.
75
-			if($this->project->repoExists() && empty($this->args['forceClone'])) {
75
+			if ($this->project->repoExists() && empty($this->args['forceClone'])) {
76 76
 				$this->fetchRepo();
77 77
 			} else {
78 78
 				$this->cloneRepo();
79 79
 			}
80
-		} catch(Exception $e) {
81
-			if($this->log) {
80
+		} catch (Exception $e) {
81
+			if ($this->log) {
82 82
 				$this->log->write($e->getMessage());
83 83
 			}
84 84
 			throw $e;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	protected function cloneRepo() {
98
-		if(file_exists($this->project->getLocalCVSPath())) {
98
+		if (file_exists($this->project->getLocalCVSPath())) {
99 99
 			$this->runCommand(sprintf(
100 100
 				'rm -rf %s',
101 101
 				escapeshellarg($this->project->getLocalCVSPath())
@@ -117,17 +117,17 @@  discard block
 block discarded – undo
117 117
 	 * @throws RuntimeException
118 118
 	 */
119 119
 	protected function runCommand($command, $workingDir = null) {
120
-		if(!empty($this->user)) {
120
+		if (!empty($this->user)) {
121 121
 			$command = sprintf('sudo -u %s %s', $this->user, $command);
122 122
 		}
123
-		if($this->log) {
123
+		if ($this->log) {
124 124
 			$this->log->write(sprintf('Running command: %s', $command));
125 125
 		}
126 126
 		$process = new AbortableProcess($command, $workingDir);
127 127
 		$process->setEnv($this->project->getProcessEnv());
128 128
 		$process->setTimeout(1800);
129 129
 		$process->run();
130
-		if(!$process->isSuccessful()) {
130
+		if (!$process->isSuccessful()) {
131 131
 			throw new RuntimeException($process->getErrorOutput());
132 132
 		}
133 133
 	}
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 		global $databaseConfig;
141 141
 		DB::connect($databaseConfig);
142 142
 
143
-		if(!empty($this->args['fetchID'])) {
143
+		if (!empty($this->args['fetchID'])) {
144 144
 			$fetch = DNGitFetch::get()->byID($this->args['fetchID']);
145
-			if($fetch && $fetch->exists()) {
145
+			if ($fetch && $fetch->exists()) {
146 146
 				$fetch->Status = $status;
147 147
 				$fetch->write();
148 148
 			}
Please login to merge, or discard this patch.
code/form/TabbedSelectionGroup.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 		$items = CompositeField::FieldList()->toArray();
10 10
 		$fields = new ArrayList();
11 11
 
12
-		foreach($items as $item) {
12
+		foreach ($items as $item) {
13 13
 			$extra = array(
14 14
 				'Selected' => $this->value == $item->getValue(),
15 15
 			);
Please login to merge, or discard this patch.
code/form/DataArchiveFileField.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 	 * @return bool|DataArchiveFileField
16 16
 	 */
17 17
 	public function saveInto(DataObjectInterface $record) {
18
-		if(!isset($_FILES[$this->name])) {
18
+		if (!isset($_FILES[$this->name])) {
19 19
 			return false;
20 20
 		}
21 21
 
22
-		if(!($record instanceof DNDataArchive)) {
22
+		if (!($record instanceof DNDataArchive)) {
23 23
 			throw new LogicException('Saving into wrong type, expected DNDataArchive');
24 24
 		}
25 25
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 		/** @var DNDataTransfer $dataTransfer */
29 29
 		$dataTransfer = $dataArchive->DataTransfers()->First();
30
-		if(!$dataTransfer) {
30
+		if (!$dataTransfer) {
31 31
 			throw new LogicException('No transfer found');
32 32
 		}
33 33
 
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
 		// Hack: loadIntoFile assumes paths relative to assets,
37 37
 		//  otherwise it creates the whole structure *within* that folder
38 38
 		$absolutePath = $dataArchive->generateFilepath($dataTransfer);
39
-		$relativePath = preg_replace('#^' . preg_quote(ASSETS_PATH) . '/#', '', $absolutePath);
39
+		$relativePath = preg_replace('#^'.preg_quote(ASSETS_PATH).'/#', '', $absolutePath);
40 40
 		$this->upload->loadIntoFile($_FILES[$this->name], $file, $relativePath);
41
-		if($this->upload->isError()) {
41
+		if ($this->upload->isError()) {
42 42
 			return false;
43 43
 		}
44 44
 
45 45
 		$file = $this->upload->getFile();
46
-		if($this->relationAutoSetting) {
46
+		if ($this->relationAutoSetting) {
47 47
 			// save to record
48
-			$record->{$this->name . 'ID'} = $file->ID;
48
+			$record->{$this->name.'ID'} = $file->ID;
49 49
 		}
50 50
 
51 51
 		return $this;
Please login to merge, or discard this patch.
code/extensions/DeploynautSecurityExtension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 		// the 'ping' action is called via AJAX from the /admin and will cause
7 7
 		// the admin section to 'grow' over time. We only need the css and js
8 8
 		// for login, reset, logout and so on.
9
-		if(!$this->owner->getRequest()->isAjax()) {
9
+		if (!$this->owner->getRequest()->isAjax()) {
10 10
 			DNRoot::include_requirements();
11 11
 		}
12 12
 	}
Please login to merge, or discard this patch.
code/extensions/DeploynautFileExtension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 		$file = $this->owner;
12 12
 		$archive = DNDataArchive::get()->filter('ArchiveFileID', $file->ID)->First();
13 13
 
14
-		if($archive) {
14
+		if ($archive) {
15 15
 			return $archive->canDownload($member);
16 16
 		}
17 17
 
Please login to merge, or discard this patch.