Passed
Branch master (f497d2)
by Mike
03:18
created
lib/request/gethierarchy.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@
 block discarded – undo
24 24
 			}
25 25
 
26 26
 			// TODO execute $data->Check() to see if SyncObject is valid
27
-		}
28
-		catch (StatusException $ex) {
27
+		} catch (StatusException $ex) {
29 28
 			return false;
30 29
 		}
31 30
 
Please login to merge, or discard this patch.
lib/request/foldersync.php 1 patch
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -49,11 +49,9 @@  discard block
 block discarded – undo
49 49
 
50 50
 			// there are no SyncParameters for the hierarchy, but we use it to save the latest synckeys
51 51
 			$spa = self::$deviceManager->GetStateManager()->GetSynchedFolderState(false);
52
-		}
53
-		catch (StateNotFoundException $snfex) {
52
+		} catch (StateNotFoundException $snfex) {
54 53
 			$status = SYNC_FSSTATUS_SYNCKEYERROR;
55
-		}
56
-		catch (StateInvalidException $sive) {
54
+		} catch (StateInvalidException $sive) {
57 55
 			$status = SYNC_FSSTATUS_SYNCKEYERROR;
58 56
 		}
59 57
 
@@ -116,13 +114,11 @@  discard block
 block discarded – undo
116 114
 								$serverid = $changesMem->ImportFolderDeletion($folder);
117 115
 								break;
118 116
 						}
119
-					}
120
-					else {
117
+					} else {
121 118
 						SLog::Write(LOGLEVEL_WARN, sprintf("Request->HandleFolderSync(): ignoring incoming folderchange for folder '%s' as status indicates problem.", $folder->displayname));
122 119
 						self::$topCollector->AnnounceInformation("Incoming change ignored", true);
123 120
 					}
124
-				}
125
-				catch (StatusException $stex) {
121
+				} catch (StatusException $stex) {
126 122
 					$status = $stex->getCode();
127 123
 				}
128 124
 			}
@@ -199,12 +195,10 @@  discard block
 block discarded – undo
199 195
 
200 196
 				// get the new state from the backend
201 197
 				$newsyncstate = (isset($exporter)) ? $exporter->GetState() : "";
202
-			}
203
-			catch (StatusException $stex) {
198
+			} catch (StatusException $stex) {
204 199
 				if ($stex->getCode() == SYNC_FSSTATUS_CODEUNKNOWN) {
205 200
 					$status = SYNC_FSSTATUS_SYNCKEYERROR;
206
-				}
207
-				else {
201
+				} else {
208 202
 					$status = $stex->getCode();
209 203
 				}
210 204
 			}
Please login to merge, or discard this patch.
lib/request/folderchange.php 1 patch
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -26,11 +26,9 @@  discard block
 block discarded – undo
26 26
 		$create = $update = $delete = false;
27 27
 		if ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERCREATE) {
28 28
 			$create = true;
29
-		}
30
-		elseif ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERUPDATE) {
29
+		} elseif ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERUPDATE) {
31 30
 			$update = true;
32
-		}
33
-		elseif ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERDELETE) {
31
+		} elseif ($el[EN_TAG] == SYNC_FOLDERHIERARCHY_FOLDERDELETE) {
34 32
 			$delete = true;
35 33
 		}
36 34
 
@@ -130,11 +128,9 @@  discard block
 block discarded – undo
130 128
 			if (self::$deviceManager->GetFolderTypeFromCacheById($serverid) != SYNC_FOLDER_TYPE_UNKNOWN && !self::$backend->Setup(GSync::GetAdditionalSyncFolderStore((($parentBackendId != false) ? $parentBackendId : $backendid)))) {
131 129
 				throw new StatusException(sprintf("HandleFolderChange() could not Setup() the backend for folder id '%s'", (($parentBackendId != false) ? $parentBackendId : $backendid)), SYNC_FSSTATUS_SERVERERROR);
132 130
 			}
133
-		}
134
-		catch (StateNotFoundException $snfex) {
131
+		} catch (StateNotFoundException $snfex) {
135 132
 			$status = SYNC_FSSTATUS_SYNCKEYERROR;
136
-		}
137
-		catch (StatusException $stex) {
133
+		} catch (StatusException $stex) {
138 134
 			$status = $stex->getCode();
139 135
 		}
140 136
 
@@ -169,13 +165,11 @@  discard block
 block discarded – undo
169 165
 				if (!$delete) {
170 166
 					// when creating, $folder->serverid is false, and the returned id is already mapped by the backend
171 167
 					$folder = $changesMem->ImportFolderChange($folder);
172
-				}
173
-				else {
168
+				} else {
174 169
 					// delete folder
175 170
 					$changesMem->ImportFolderDeletion($folder);
176 171
 				}
177
-			}
178
-			catch (StatusException $stex) {
172
+			} catch (StatusException $stex) {
179 173
 				$status = $stex->getCode();
180 174
 			}
181 175
 		}
@@ -197,8 +191,7 @@  discard block
 block discarded – undo
197 191
 			self::$encoder->endTag();
198 192
 
199 193
 			self::$encoder->endTag();
200
-		}
201
-		elseif ($update) {
194
+		} elseif ($update) {
202 195
 			self::$encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDERUPDATE);
203 196
 
204 197
 			self::$encoder->startTag(SYNC_FOLDERHIERARCHY_STATUS);
@@ -210,8 +203,7 @@  discard block
 block discarded – undo
210 203
 			self::$encoder->endTag();
211 204
 
212 205
 			self::$encoder->endTag();
213
-		}
214
-		elseif ($delete) {
206
+		} elseif ($delete) {
215 207
 			self::$encoder->startTag(SYNC_FOLDERHIERARCHY_FOLDERDELETE);
216 208
 
217 209
 			self::$encoder->startTag(SYNC_FOLDERHIERARCHY_STATUS);
Please login to merge, or discard this patch.
lib/request/moveitems.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,12 +92,10 @@
 block discarded – undo
92 92
 
93 93
 				$result = $importer->ImportMessageMove($move["srcmsgid"], self::$deviceManager->GetBackendIdForFolderId($move["dstfldid"]));
94 94
 				// We discard the standard importer state for now.
95
-			}
96
-			catch (StatusException $stex) {
95
+			} catch (StatusException $stex) {
97 96
 				if ($stex->getCode() == SYNC_STATUS_FOLDERHIERARCHYCHANGED) { // same as SYNC_FSSTATUS_CODEUNKNOWN
98 97
 					$status = SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID;
99
-				}
100
-				else {
98
+				} else {
101 99
 					$status = $stex->getCode();
102 100
 				}
103 101
 			}
Please login to merge, or discard this patch.
lib/request/validatecert.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@
 block discarded – undo
29 29
 		$checkpurpose = (defined('CAINFO') && CAINFO) ? openssl_x509_checkpurpose($cert_pem, X509_PURPOSE_SMIME_SIGN, [CAINFO]) : openssl_x509_checkpurpose($cert_pem, X509_PURPOSE_SMIME_SIGN);
30 30
 		if ($checkpurpose === true) {
31 31
 			$status = SYNC_VALIDATECERTSTATUS_SUCCESS;
32
-		}
33
-		else {
32
+		} else {
34 33
 			$status = SYNC_VALIDATECERTSTATUS_CANTVALIDATESIG;
35 34
 		}
36 35
 
Please login to merge, or discard this patch.
lib/request/ping.php 1 patch
Braces   +14 added lines, -28 removed lines patch added patch discarded remove patch
@@ -30,27 +30,23 @@  discard block
 block discarded – undo
30 30
 		// Load all collections - do load states, check permissions and allow unconfirmed states
31 31
 		try {
32 32
 			$sc->LoadAllCollections(true, true, true, true, false);
33
-		}
34
-		catch (StateInvalidException $siex) {
33
+		} catch (StateInvalidException $siex) {
35 34
 			// if no params are present, indicate to send params, else do hierarchy sync
36 35
 			if (!$params_present) {
37 36
 				$pingstatus = SYNC_PINGSTATUS_FAILINGPARAMS;
38 37
 				self::$topCollector->AnnounceInformation("StateInvalidException: require PingParameters", true);
39
-			}
40
-			elseif (self::$deviceManager->IsHierarchySyncRequired()) {
38
+			} elseif (self::$deviceManager->IsHierarchySyncRequired()) {
41 39
 				// we could be in a looping  - see LoopDetection->ProcessLoopDetectionIsHierarchySyncAdvised()
42 40
 				$pingstatus = SYNC_PINGSTATUS_FOLDERHIERSYNCREQUIRED;
43 41
 				self::$topCollector->AnnounceInformation("Potential loop detection: require HierarchySync", true);
44
-			}
45
-			else {
42
+			} else {
46 43
 				// we do not have a ping status for this, but SyncCollections should have generated fake changes for the folders which are broken
47 44
 				$fakechanges = $sc->GetChangedFolderIds();
48 45
 				$foundchanges = true;
49 46
 
50 47
 				self::$topCollector->AnnounceInformation("StateInvalidException: force sync", true);
51 48
 			}
52
-		}
53
-		catch (StatusException $stex) {
49
+		} catch (StatusException $stex) {
54 50
 			$pingstatus = SYNC_PINGSTATUS_FOLDERHIERSYNCREQUIRED;
55 51
 			self::$topCollector->AnnounceInformation("StatusException: require HierarchySync", true);
56 52
 		}
@@ -103,8 +99,7 @@  discard block
 block discarded – undo
103 99
 
104 100
 								continue;
105 101
 							}
106
-						}
107
-						catch (NoHierarchyCacheAvailableException $nhca) {
102
+						} catch (NoHierarchyCacheAvailableException $nhca) {
108 103
 							SLog::Write(LOGLEVEL_INFO, sprintf("HandlePing(): unknown collection '%s', triggering HierarchySync", $folderid));
109 104
 							$pingstatus = SYNC_PINGSTATUS_FOLDERHIERSYNCREQUIRED;
110 105
 						}
@@ -112,8 +107,7 @@  discard block
 block discarded – undo
112 107
 						// Trigger a Sync request because then the device will be forced to resync this folder.
113 108
 						$fakechanges[$folderid] = 1;
114 109
 						$foundchanges = true;
115
-					}
116
-					elseif ($class == $spa->GetContentClass()) {
110
+					} elseif ($class == $spa->GetContentClass()) {
117 111
 						$pingable[] = $folderid;
118 112
 						SLog::Write(LOGLEVEL_DEBUG, sprintf("HandlePing(): using saved sync state for '%s' id '%s'", $spa->GetContentClass(), $folderid));
119 113
 					}
@@ -127,8 +121,7 @@  discard block
 block discarded – undo
127 121
 					// if the folderid is in $pingable, we should ping it, else remove the flag
128 122
 					if (in_array($folderid, $pingable)) {
129 123
 						$spa->SetPingableFlag(true);
130
-					}
131
-					else {
124
+					} else {
132 125
 						$spa->DelPingableFlag();
133 126
 					}
134 127
 				}
@@ -152,8 +145,7 @@  discard block
 block discarded – undo
152 145
 			if (!$sc->PingableFolders()) {
153 146
 				$pingstatus = SYNC_PINGSTATUS_FAILINGPARAMS;
154 147
 				SLog::Write(LOGLEVEL_DEBUG, "HandlePing(): no pingable folders found and no initialization data sent. Returning SYNC_PINGSTATUS_FAILINGPARAMS.");
155
-			}
156
-			elseif (!$this->lifetimeBetweenBound($sc->GetLifetime())) {
148
+			} elseif (!$this->lifetimeBetweenBound($sc->GetLifetime())) {
157 149
 				$pingstatus = SYNC_PINGSTATUS_FAILINGPARAMS;
158 150
 				SLog::Write(LOGLEVEL_DEBUG, sprintf("HandlePing(): ping lifetime not between bound (higher bound:'%d' lower bound:'%d' current lifetime:'%d'. Returning SYNC_PINGSTATUS_FAILINGPARAMS.", PING_HIGHER_BOUND_LIFETIME, PING_LOWER_BOUND_LIFETIME, $sc->GetLifetime()));
159 151
 			}
@@ -165,8 +157,7 @@  discard block
 block discarded – undo
165 157
 				self::$deviceManager->DoAutomaticASDeviceSaving(false);
166 158
 				$foundchanges = $sc->CheckForChanges($sc->GetLifetime(), $interval, true);
167 159
 			}
168
-		}
169
-		catch (StatusException $ste) {
160
+		} catch (StatusException $ste) {
170 161
 			switch ($ste->getCode()) {
171 162
 				case SyncCollections::ERROR_NO_COLLECTIONS:
172 163
 					$pingstatus = SYNC_PINGSTATUS_FAILINGPARAMS;
@@ -193,8 +184,7 @@  discard block
 block discarded – undo
193 184
 		self::$encoder->startTag(SYNC_PING_STATUS);
194 185
 		if (isset($pingstatus) && $pingstatus) {
195 186
 			self::$encoder->content($pingstatus);
196
-		}
197
-		else {
187
+		} else {
198 188
 			self::$encoder->content($foundchanges ? SYNC_PINGSTATUS_CHANGES : SYNC_PINGSTATUS_HBEXPIRED);
199 189
 		}
200 190
 		self::$encoder->endTag();
@@ -204,8 +194,7 @@  discard block
 block discarded – undo
204 194
 
205 195
 			if (empty($fakechanges)) {
206 196
 				$changes = $sc->GetChangedFolderIds();
207
-			}
208
-			else {
197
+			} else {
209 198
 				$changes = $fakechanges;
210 199
 			}
211 200
 
@@ -222,8 +211,7 @@  discard block
 block discarded – undo
222 211
 						if (empty($fakechanges)) {
223 212
 							self::$topCollector->AnnounceInformation(sprintf("Found change in %s", $sc->GetCollection($folderid)->GetContentClass()), true);
224 213
 						}
225
-					}
226
-					else {
214
+					} else {
227 215
 						$announceAggregated += $changecount;
228 216
 					}
229 217
 					self::$deviceManager->AnnounceProcessStatus($folderid, SYNC_PINGSTATUS_CHANGES);
@@ -233,13 +221,11 @@  discard block
 block discarded – undo
233 221
 				self::$topCollector->AnnounceInformation(sprintf("Found %d changes in %d folders", $announceAggregated, count($changes)), true);
234 222
 			}
235 223
 			self::$encoder->endTag();
236
-		}
237
-		elseif ($pingstatus == SYNC_PINGSTATUS_HBOUTOFRANGE) {
224
+		} elseif ($pingstatus == SYNC_PINGSTATUS_HBOUTOFRANGE) {
238 225
 			self::$encoder->startTag(SYNC_PING_LIFETIME);
239 226
 			if ($sc->GetLifetime() > PING_HIGHER_BOUND_LIFETIME) {
240 227
 				self::$encoder->content(PING_HIGHER_BOUND_LIFETIME);
241
-			}
242
-			else {
228
+			} else {
243 229
 				self::$encoder->content(PING_LOWER_BOUND_LIFETIME);
244 230
 			}
245 231
 			self::$encoder->endTag();
Please login to merge, or discard this patch.
lib/request/itemoperations.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -39,13 +39,11 @@  discard block
 block discarded – undo
39 39
 				$fetch = true;
40 40
 				$operation['operation'] = SYNC_ITEMOPERATIONS_FETCH;
41 41
 				self::$topCollector->AnnounceInformation("Fetch", true);
42
-			}
43
-			elseif ($el[EN_TAG] == SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS) {
42
+			} elseif ($el[EN_TAG] == SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS) {
44 43
 				$efc = true;
45 44
 				$operation['operation'] = SYNC_ITEMOPERATIONS_EMPTYFOLDERCONTENTS;
46 45
 				self::$topCollector->AnnounceInformation("Empty Folder", true);
47
-			}
48
-			elseif ($el[EN_TAG] == SYNC_ITEMOPERATIONS_MOVE) {
46
+			} elseif ($el[EN_TAG] == SYNC_ITEMOPERATIONS_MOVE) {
49 47
 				$move = true;
50 48
 				$operation['operation'] = SYNC_ITEMOPERATIONS_MOVE;
51 49
 				self::$topCollector->AnnounceInformation("Move", true);
@@ -315,24 +313,20 @@  discard block
 block discarded – undo
315 313
 					try {
316 314
 						self::$topCollector->AnnounceInformation("Get attachment data from backend with file reference");
317 315
 						$data = self::$backend->GetAttachmentData($operation['filereference']);
318
-					}
319
-					catch (StatusException $stex) {
316
+					} catch (StatusException $stex) {
320 317
 						$status = $stex->getCode();
321 318
 					}
322
-				}
323
-				else {
319
+				} else {
324 320
 					try {
325 321
 						if (isset($operation['folderid'], $operation['serverid'])) {
326 322
 							self::$topCollector->AnnounceInformation("Fetching data from backend with item and folder id");
327 323
 							$data = self::$backend->Fetch($operation['backendfolderid'], $operation['serverid'], $operation["cpo"]);
328
-						}
329
-						elseif (isset($operation['longid'])) {
324
+						} elseif (isset($operation['longid'])) {
330 325
 							self::$topCollector->AnnounceInformation("Fetching data from backend with long id");
331 326
 							$tmp = explode(":", $operation['longid']);
332 327
 							$data = self::$backend->Fetch(self::$deviceManager->GetBackendIdForFolderId($tmp[0]), $tmp[1], $operation["cpo"]);
333 328
 						}
334
-					}
335
-					catch (StatusException $stex) {
329
+					} catch (StatusException $stex) {
336 330
 						// the only option to return is that we could not retrieve it
337 331
 						$status = SYNC_ITEMOPERATIONSSTATUS_CONVERSIONFAILED;
338 332
 					}
@@ -396,8 +390,7 @@  discard block
 block discarded – undo
396 390
 
397 391
 					// send request to backend
398 392
 					self::$backend->EmptyFolder($operation['backendfolderid'], $operation['deletesubfolders']);
399
-				}
400
-				catch (StatusException $stex) {
393
+				} catch (StatusException $stex) {
401 394
 					$status = $stex->getCode();
402 395
 				}
403 396
 
Please login to merge, or discard this patch.
lib/request/provisioning.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -138,8 +138,7 @@  discard block
 block discarded – undo
138 138
 					if (!$wipeRequest) {
139 139
 						// for this operation the device manager is available
140 140
 						GSync::GetDeviceManager()->SaveDeviceInformation($deviceinformation);
141
-					}
142
-					else {
141
+					} else {
143 142
 						SLog::Write(LOGLEVEL_DEBUG, "Ignoring incoming device information as WIPE is due.");
144 143
 					}
145 144
 					if (!self::$decoder->getElementEndTag()) {  // SYNC_SETTINGS_SET
@@ -205,8 +204,7 @@  discard block
 block discarded – undo
205 204
 			self::$encoder->startTag(SYNC_PROVISION_DATA);
206 205
 			if ($policytype == 'MS-WAP-Provisioning-XML') {
207 206
 				self::$encoder->content('<wap-provisioningdoc><characteristic type="SecurityPolicy"><parm name="4131" value="1"/><parm name="4133" value="1"/></characteristic></wap-provisioningdoc>');
208
-			}
209
-			elseif ($policytype == 'MS-EAS-Provisioning-WBXML') {
207
+			} elseif ($policytype == 'MS-EAS-Provisioning-WBXML') {
210 208
 				self::$encoder->startTag(SYNC_PROVISION_EASPROVISIONDOC);
211 209
 
212 210
 				// get the provisioning object and log the loaded policy values
@@ -218,8 +216,7 @@  discard block
 block discarded – undo
218 216
 				GSync::GetProvisioningManager()->SavePolicyHash($prov);
219 217
 				$prov->Encode(self::$encoder);
220 218
 				self::$encoder->endTag();
221
-			}
222
-			else {
219
+			} else {
223 220
 				SLog::Write(LOGLEVEL_WARN, "Wrong policy type");
224 221
 				self::$topCollector->AnnounceInformation("Policytype not supported", true);
225 222
 
Please login to merge, or discard this patch.
lib/request/request.php 1 patch
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -194,8 +194,7 @@  discard block
 block discarded – undo
194 194
 		$memoryLimit = ini_get('memory_limit');
195 195
 		if ($memoryLimit == -1) {
196 196
 			self::$memoryLimit = false;
197
-		}
198
-		else {
197
+		} else {
199 198
 			preg_replace_callback(
200 199
 				'/(\-?\d+)(.?)/',
201 200
 				function ($m) {
@@ -223,8 +222,7 @@  discard block
 block discarded – undo
223 222
 		if (!isset(self::$policykey)) {
224 223
 			if (isset(self::$headers["x-ms-policykey"])) {
225 224
 				self::$policykey = (int) self::filterEvilInput(self::$headers["x-ms-policykey"], self::NUMBERS_ONLY);
226
-			}
227
-			else {
225
+			} else {
228 226
 				self::$policykey = 0;
229 227
 			}
230 228
 		}
@@ -661,8 +659,7 @@  discard block
 block discarded – undo
661 659
 			// Samsung devices have a intermediate timeout (90sec)
662 660
 			elseif (stripos(SYNC_TIMEOUT_MEDIUM_DEVICETYPES, self::GetDeviceType()) !== false) {
663 661
 				self::$expectedConnectionTimeout = 85;
664
-			}
665
-			else {
662
+			} else {
666 663
 				// for all other devices, a timeout of 30 seconds is expected
667 664
 				self::$expectedConnectionTimeout = 28;
668 665
 			}
@@ -713,23 +710,17 @@  discard block
 block discarded – undo
713 710
 		$re = false;
714 711
 		if ($filter == self::LETTERS_ONLY) {
715 712
 			$re = "/[^A-Za-z]/";
716
-		}
717
-		elseif ($filter == self::HEX_ONLY) {
713
+		} elseif ($filter == self::HEX_ONLY) {
718 714
 			$re = "/[^A-Fa-f0-9]/";
719
-		}
720
-		elseif ($filter == self::WORDCHAR_ONLY) {
715
+		} elseif ($filter == self::WORDCHAR_ONLY) {
721 716
 			$re = "/[^A-Za-z0-9]/";
722
-		}
723
-		elseif ($filter == self::NUMBERS_ONLY) {
717
+		} elseif ($filter == self::NUMBERS_ONLY) {
724 718
 			$re = "/[^0-9]/";
725
-		}
726
-		elseif ($filter == self::NUMBERSDOT_ONLY) {
719
+		} elseif ($filter == self::NUMBERSDOT_ONLY) {
727 720
 			$re = "/[^0-9\\.]/";
728
-		}
729
-		elseif ($filter == self::HEX_EXTENDED) {
721
+		} elseif ($filter == self::HEX_EXTENDED) {
730 722
 			$re = "/[^A-Fa-f0-9\\:\\.]/";
731
-		}
732
-		elseif ($filter == self::HEX_EXTENDED2) {
723
+		} elseif ($filter == self::HEX_EXTENDED2) {
733 724
 			$re = "/[^A-Fa-f0-9\\:USGI]/";
734 725
 		} // Folder origin constants from DeviceManager::FLD_ORIGIN_* (C already hex)
735 726
 		elseif ($filter == self::ISO8601) {
Please login to merge, or discard this patch.