Passed
Branch master (f497d2)
by Mike
03:18
created
lib/request/request.php 2 patches
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.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 class Request {
11
-	public const MAXMEMORYUSAGE = 0.9;     // use max. 90% of allowed memory when syncing
11
+	public const MAXMEMORYUSAGE = 0.9; // use max. 90% of allowed memory when syncing
12 12
 	public const UNKNOWN = "unknown";
13 13
 	public const IMPERSONATE_DELIM = '#';
14 14
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 			}
141 141
 
142 142
 			if (isset(self::$base64QueryDecoded['PolKey'])) {
143
-				self::$policykey = (int) self::filterEvilInput(self::$base64QueryDecoded['PolKey'], self::NUMBERS_ONLY);
143
+				self::$policykey = (int)self::filterEvilInput(self::$base64QueryDecoded['PolKey'], self::NUMBERS_ONLY);
144 144
 			}
145 145
 
146 146
 			if (isset(self::$base64QueryDecoded['ProtVer'])) {
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 		else {
199 199
 			preg_replace_callback(
200 200
 				'/(\-?\d+)(.?)/',
201
-				function ($m) {
201
+				function($m) {
202 202
 					self::$memoryLimit = $m[1] * pow(1024, strpos('BKMG', $m[2])) * self::MAXMEMORYUSAGE;
203 203
 				},
204 204
 				strtoupper($memoryLimit)
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		// the policy key might be set in Request::Initialize from the base64 encoded query
223 223
 		if (!isset(self::$policykey)) {
224 224
 			if (isset(self::$headers["x-ms-policykey"])) {
225
-				self::$policykey = (int) self::filterEvilInput(self::$headers["x-ms-policykey"], self::NUMBERS_ONLY);
225
+				self::$policykey = (int)self::filterEvilInput(self::$headers["x-ms-policykey"], self::NUMBERS_ONLY);
226 226
 			}
227 227
 			else {
228 228
 				self::$policykey = 0;
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 	 * @return int
638 638
 	 */
639 639
 	public static function GetContentLength() {
640
-		return (isset(self::$headers["content-length"])) ? (int) self::$headers["content-length"] : 0;
640
+		return (isset(self::$headers["content-length"])) ? (int)self::$headers["content-length"] : 0;
641 641
 	}
642 642
 
643 643
 	/**
Please login to merge, or discard this patch.
lib/request/getitemestimate.php 2 patches
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -38,16 +38,14 @@  discard block
 block discarded – undo
38 38
 				if (self::$decoder->getElementStartTag(SYNC_SYNCKEY)) {
39 39
 					try {
40 40
 						$spa->SetSyncKey(self::$decoder->getElementContent());
41
-					}
42
-					catch (StateInvalidException $siex) {
41
+					} catch (StateInvalidException $siex) {
43 42
 						$spastatus = SYNC_GETITEMESTSTATUS_SYNCSTATENOTPRIMED;
44 43
 					}
45 44
 
46 45
 					if (!self::$decoder->getElementEndTag()) {
47 46
 						return false;
48 47
 					}
49
-				}
50
-				elseif (self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERID)) {
48
+				} elseif (self::$decoder->getElementStartTag(SYNC_GETITEMESTIMATE_FOLDERID)) {
51 49
 					$fid = self::$decoder->getElementContent();
52 50
 					$spa->SetFolderId($fid);
53 51
 					$spa->SetBackendFolderId(self::$deviceManager->GetBackendIdForFolderId($fid));
@@ -149,8 +147,7 @@  discard block
 block discarded – undo
149 147
 			if (!$spa->HasContentClass() && $spa->HasFolderId()) {
150 148
 				try {
151 149
 					$spa->SetContentClass(self::$deviceManager->GetFolderClassFromCacheByID($spa->GetFolderId()));
152
-				}
153
-				catch (NoHierarchyCacheAvailableException $nhca) {
150
+				} catch (NoHierarchyCacheAvailableException $nhca) {
154 151
 					$spastatus = SYNC_GETITEMESTSTATUS_COLLECTIONINVALID;
155 152
 				}
156 153
 			}
@@ -165,8 +162,7 @@  discard block
 block discarded – undo
165 162
 			if ($spastatus) {
166 163
 				// the CPO has a folder id now, so we can set the status
167 164
 				$sc->AddParameter($spa, "status", $spastatus);
168
-			}
169
-			else {
165
+			} else {
170 166
 				try {
171 167
 					$sc->AddParameter($spa, "state", self::$deviceManager->GetStateManager()->GetSyncState($spa->GetSyncKey()));
172 168
 
@@ -174,26 +170,22 @@  discard block
 block discarded – undo
174 170
 					if (!self::$backend->Setup(GSync::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) {
175 171
 						throw new StatusException(sprintf("HandleGetItemEstimate() could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_GETITEMESTSTATUS_COLLECTIONINVALID);
176 172
 					}
177
-				}
178
-				catch (StateNotFoundException $snfex) {
173
+				} catch (StateNotFoundException $snfex) {
179 174
 					// ok, the key is invalid. Question is, if the hierarchycache is still ok
180 175
 					// if not, we have to issue SYNC_GETITEMESTSTATUS_COLLECTIONINVALID which triggers a FolderSync
181 176
 					try {
182 177
 						self::$deviceManager->GetFolderClassFromCacheByID($spa->GetFolderId());
183 178
 						// we got here, so the HierarchyCache is ok
184 179
 						$sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_SYNCKKEYINVALID);
185
-					}
186
-					catch (NoHierarchyCacheAvailableException $nhca) {
180
+					} catch (NoHierarchyCacheAvailableException $nhca) {
187 181
 						$sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_COLLECTIONINVALID);
188 182
 					}
189 183
 
190 184
 					self::$topCollector->AnnounceInformation("StateNotFoundException " . $sc->GetParameter($spa, "status"), true);
191
-				}
192
-				catch (StatusException $stex) {
185
+				} catch (StatusException $stex) {
193 186
 					if ($stex->getCode() == SYNC_GETITEMESTSTATUS_COLLECTIONINVALID) {
194 187
 						$sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_COLLECTIONINVALID);
195
-					}
196
-					else {
188
+					} else {
197 189
 						$sc->AddParameter($spa, "status", SYNC_GETITEMESTSTATUS_SYNCSTATENOTPRIMED);
198 190
 					}
199 191
 					self::$topCollector->AnnounceInformation("StatusException " . $sc->GetParameter($spa, "status"), true);
@@ -216,8 +208,7 @@  discard block
 block discarded – undo
216 208
 
217 209
 		try {
218 210
 			$sc->CountChanges();
219
-		}
220
-		catch (StatusException $ste) {
211
+		} catch (StatusException $ste) {
221 212
 			$status = SYNC_GETITEMESTSTATUS_COLLECTIONINVALID;
222 213
 		}
223 214
 		$changes = $sc->GetChangedFolderIds();
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 				elseif (self::$decoder->getElementStartTag(SYNC_CONVERSATIONMODE)) {
62 62
 					$spa->SetConversationMode(true);
63 63
 					if (($conversationmode = self::$decoder->getElementContent()) !== false) {
64
-						$spa->SetConversationMode((bool) $conversationmode);
64
+						$spa->SetConversationMode((bool)$conversationmode);
65 65
 						if (!self::$decoder->getElementEndTag()) {
66 66
 							return false;
67 67
 						}
Please login to merge, or discard this patch.
lib/request/search.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -145,8 +145,7 @@  discard block
 block discarded – undo
145 145
 				if (!self::$decoder->getElementEndTag()) { // SYNC_SEARCH_AND
146 146
 					return false;
147 147
 				}
148
-			}
149
-			elseif (self::$decoder->getElementStartTag(SYNC_SEARCH_EQUALTO)) {
148
+			} elseif (self::$decoder->getElementStartTag(SYNC_SEARCH_EQUALTO)) {
150 149
 				// linkid can be an empty tag as well as have value
151 150
 				if (self::$decoder->getElementStartTag(SYNC_DOCUMENTLIBRARY_LINKID)) {
152 151
 					if (($linkId = self::$decoder->getElementContent()) !== false) {
@@ -346,18 +345,15 @@  discard block
 block discarded – undo
346 345
 				if ($searchname == ISearchProvider::SEARCH_GAL) {
347 346
 					// get search results from the searchprovider
348 347
 					$rows = $searchprovider->GetGALSearchResults($searchquery, $searchrange, $searchpicture);
349
-				}
350
-				elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) {
348
+				} elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) {
351 349
 					$backendFolderId = self::$deviceManager->GetBackendIdForFolderId($cpo->GetSearchFolderid());
352 350
 					$cpo->SetSearchFolderid($backendFolderId);
353 351
 					$rows = $searchprovider->GetMailboxSearchResults($cpo);
354 352
 				}
355
-			}
356
-			catch (StatusException $stex) {
353
+			} catch (StatusException $stex) {
357 354
 				$storestatus = $stex->getCode();
358 355
 			}
359
-		}
360
-		else {
356
+		} else {
361 357
 			$rows = ['searchtotal' => 0];
362 358
 			$status = SYNC_SEARCHSTATUS_SERVERERROR;
363 359
 			SLog::Write(LOGLEVEL_WARN, sprintf("Searchtype '%s' is not supported.", $searchname));
@@ -471,8 +467,7 @@  discard block
 block discarded – undo
471 467
 								self::$encoder->endTag(); // properties
472 468
 					}
473 469
 				}
474
-			}
475
-			elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) {
470
+			} elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) {
476 471
 				foreach ($rows as $u) {
477 472
 					// TODO: unclear if any clients *require* the folder id where the message is located (it's not available anymore)
478 473
 					// $folderid = self::$deviceManager->GetFolderIdForBackendId($u['folderid']);
Please login to merge, or discard this patch.
lib/request/requestprocessor.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -98,8 +98,7 @@
 block discarded – undo
98 98
 			if (!$handler->Handle(Request::GetCommandCode())) {
99 99
 				throw new WBXMLException(sprintf("Unknown error in %s->Handle()", get_class($handler)));
100 100
 			}
101
-		}
102
-		catch (Exception $ex) {
101
+		} catch (Exception $ex) {
103 102
 			// Log 10 KB of the WBXML data
104 103
 			SLog::Write(LOGLEVEL_FATAL, "WBXML 10K debug data: " . Request::GetInputAsBase64(10240), false);
105 104
 
Please login to merge, or discard this patch.
lib/request/getattachment.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@
 block discarded – undo
40 40
 			}
41 41
 			self::$topCollector->AnnounceInformation(sprintf("Streamed %d KB attachment", round($l / 1024)), true);
42 42
 			SLog::Write(LOGLEVEL_DEBUG, sprintf("HandleGetAttachment(): attachment with %d KB sent to mobile", round($l / 1024)));
43
-		}
44
-		catch (StatusException $s) {
43
+		} catch (StatusException $s) {
45 44
 			// StatusException already logged so we just need to pass it upwards to send a HTTP error
46 45
 			throw new HTTPReturnCodeException($s->getMessage(), HTTP_CODE_500, null, LOGLEVEL_DEBUG);
47 46
 		}
Please login to merge, or discard this patch.
lib/request/sendmail.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
 		}
25 25
 		if ($commandCode == GSync::COMMAND_SMARTFORWARD) {
26 26
 			$forward = Request::GetGETItemId();
27
-		}
28
-		elseif ($commandCode == GSync::COMMAND_SMARTREPLY) {
27
+		} elseif ($commandCode == GSync::COMMAND_SMARTREPLY) {
29 28
 			$reply = Request::GetGETItemId();
30 29
 		}
31 30
 
@@ -38,11 +37,9 @@  discard block
 block discarded – undo
38 37
 
39 38
 			if ($el[EN_TAG] == SYNC_COMPOSEMAIL_SENDMAIL) {
40 39
 				$sendmail = true;
41
-			}
42
-			elseif ($el[EN_TAG] == SYNC_COMPOSEMAIL_SMARTREPLY) {
40
+			} elseif ($el[EN_TAG] == SYNC_COMPOSEMAIL_SMARTREPLY) {
43 41
 				$smartreply = true;
44
-			}
45
-			elseif ($el[EN_TAG] == SYNC_COMPOSEMAIL_SMARTFORWARD) {
42
+			} elseif ($el[EN_TAG] == SYNC_COMPOSEMAIL_SMARTFORWARD) {
46 43
 				$smartforward = true;
47 44
 			}
48 45
 
@@ -51,8 +48,7 @@  discard block
 block discarded – undo
51 48
 			}
52 49
 
53 50
 			$sm->Decode(self::$decoder);
54
-		}
55
-		else {
51
+		} else {
56 52
 			$sm->mime = self::$decoder->GetPlainInputStream();
57 53
 			// no wbxml output is provided, only a http OK
58 54
 			$sm->saveinsent = Request::GetGETSaveInSent();
@@ -92,8 +88,7 @@  discard block
 block discarded – undo
92 88
 			// Even if they are a part of SyncSendMail object, they won't be streamed.
93 89
 			if ($smartreply || $reply) {
94 90
 				$sm->replyflag = true;
95
-			}
96
-			else {
91
+			} else {
97 92
 				$sm->forwardflag = true;
98 93
 			}
99 94
 
@@ -108,8 +103,7 @@  discard block
 block discarded – undo
108 103
 
109 104
 		try {
110 105
 			$status = self::$backend->SendMail($sm);
111
-		}
112
-		catch (StatusException $se) {
106
+		} catch (StatusException $se) {
113 107
 			$status = $se->getCode();
114 108
 			$statusMessage = $se->getMessage();
115 109
 		}
@@ -123,8 +117,7 @@  discard block
 block discarded – undo
123 117
 				self::$encoder->content($status); // TODO return the correct status
124 118
 				self::$encoder->endTag();
125 119
 				self::$encoder->endTag();
126
-			}
127
-			else {
120
+			} else {
128 121
 				throw new HTTPReturnCodeException($statusMessage, HTTP_CODE_500, null, LOGLEVEL_WARN);
129 122
 			}
130 123
 		}
Please login to merge, or discard this patch.
lib/request/meetingresponse.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@
 block discarded – undo
81 81
 				if ($calendarid === false) {
82 82
 					throw new StatusException("HandleMeetingResponse() not possible", SYNC_MEETRESPSTATUS_SERVERERROR);
83 83
 				}
84
-			}
85
-			catch (StatusException $stex) {
84
+			} catch (StatusException $stex) {
86 85
 				$status = $stex->getCode();
87 86
 			}
88 87
 
Please login to merge, or discard this patch.
lib/request/sync.php 2 patches
Braces   +46 added lines, -92 removed lines patch added patch discarded remove patch
@@ -41,8 +41,7 @@  discard block
 block discarded – undo
41 41
 				SLog::Write(LOGLEVEL_INFO, "Request->HandleSync(): Sync request aborted, as exporting of folders has not yet completed");
42 42
 				self::$topCollector->AnnounceInformation("Aborted due incomplete folder sync", true);
43 43
 				$status = SYNC_STATUS_FOLDERHIERARCHYCHANGED;
44
-			}
45
-			else {
44
+			} else {
46 45
 				SLog::Write(LOGLEVEL_INFO, "Request->HandleSync(): FolderSync marked as complete");
47 46
 			}
48 47
 		}
@@ -99,8 +98,7 @@  discard block
 block discarded – undo
99 98
 								return false;
100 99
 							}
101 100
 						}
102
-					}
103
-					else {
101
+					} else {
104 102
 						return false;
105 103
 					}
106 104
 
@@ -133,16 +131,14 @@  discard block
 block discarded – undo
133 131
 							$spa->RemoveSyncKey();
134 132
 							$spa->DelFolderStat();
135 133
 							$spa->SetMoveState(false);
136
-						}
137
-						elseif ($synckey !== false) {
134
+						} elseif ($synckey !== false) {
138 135
 							if ($synckey !== $spa->GetSyncKey() && $synckey !== $spa->GetNewSyncKey()) {
139 136
 								SLog::Write(LOGLEVEL_DEBUG, "HandleSync(): Synckey does not match latest saved for this folder or there is a move state, removing folderstat to force Exporter setup");
140 137
 								$spa->DelFolderStat();
141 138
 							}
142 139
 							$spa->SetSyncKey($synckey);
143 140
 						}
144
-					}
145
-					catch (StateInvalidException $stie) {
141
+					} catch (StateInvalidException $stie) {
146 142
 						$spa = new SyncParameters();
147 143
 						$status = SYNC_STATUS_INVALIDSYNCKEY;
148 144
 						self::$topCollector->AnnounceInformation("State invalid - Resync folder", $this->singleFolder);
@@ -163,8 +159,7 @@  discard block
 block discarded – undo
163 159
 						try {
164 160
 							$spa->SetContentClass(self::$deviceManager->GetFolderClassFromCacheByID($spa->GetFolderId()));
165 161
 							SLog::Write(LOGLEVEL_DEBUG, sprintf("GetFolderClassFromCacheByID from Device Manager: '%s' for id:'%s'", $spa->GetContentClass(), $spa->GetFolderId()));
166
-						}
167
-						catch (NoHierarchyCacheAvailableException $nhca) {
162
+						} catch (NoHierarchyCacheAvailableException $nhca) {
168 163
 							$status = SYNC_STATUS_FOLDERHIERARCHYCHANGED;
169 164
 							self::$deviceManager->ForceFullResync();
170 165
 						}
@@ -176,8 +171,7 @@  discard block
 block discarded – undo
176 171
 
177 172
 					if ($spa->HasContentClass()) {
178 173
 						self::$topCollector->AnnounceInformation(sprintf("%s request", $spa->GetContentClass()), $this->singleFolder);
179
-					}
180
-					else {
174
+					} else {
181 175
 						SLog::Write(LOGLEVEL_WARN, "Not possible to determine class of request. Request did not contain class and apparently there is an issue with the HierarchyCache.");
182 176
 					}
183 177
 
@@ -480,8 +474,7 @@  discard block
 block discarded – undo
480 474
 								if (!self::$decoder->getElementEndTag()) {
481 475
 									return false;
482 476
 								}
483
-							}
484
-							else {
477
+							} else {
485 478
 								$foldertype = false;
486 479
 							}
487 480
 
@@ -500,8 +493,7 @@  discard block
 block discarded – undo
500 493
 								if (!self::$decoder->getElementEndTag()) { // end clientid
501 494
 									return false;
502 495
 								}
503
-							}
504
-							else {
496
+							} else {
505 497
 								$clientid = false;
506 498
 							}
507 499
 
@@ -516,8 +508,7 @@  discard block
 block discarded – undo
516 508
 								if (!self::$decoder->getElementEndTag()) { // end applicationdata
517 509
 									return false;
518 510
 								}
519
-							}
520
-							else {
511
+							} else {
521 512
 								$message = false;
522 513
 							}
523 514
 
@@ -534,8 +525,7 @@  discard block
 block discarded – undo
534 525
 
535 526
 									if ($status == SYNC_STATUS_SUCCESS) {
536 527
 										$this->importMessage($spa, $actiondata, $element[EN_TAG], $message, $clientid, $serverid, $foldertype, $nchanges);
537
-									}
538
-									else {
528
+									} else {
539 529
 										SLog::Write(LOGLEVEL_WARN, "Ignored incoming change, global status indicates problem.");
540 530
 									}
541 531
 									break;
@@ -543,8 +533,7 @@  discard block
 block discarded – undo
543 533
 
544 534
 							if ($actiondata["fetchids"]) {
545 535
 								self::$topCollector->AnnounceInformation(sprintf("Fetching %d", $nchanges));
546
-							}
547
-							else {
536
+							} else {
548 537
 								self::$topCollector->AnnounceInformation(sprintf("Incoming %d", $nchanges));
549 538
 							}
550 539
 
@@ -563,8 +552,7 @@  discard block
 block discarded – undo
563 552
 							try {
564 553
 								// Save the updated state, which is used for the exporter later
565 554
 								$sc->AddParameter($spa, "state", $this->importer->GetState());
566
-							}
567
-							catch (StatusException $stex) {
555
+							} catch (StatusException $stex) {
568 556
 								$status = $stex->getCode();
569 557
 							}
570 558
 						}
@@ -627,8 +615,7 @@  discard block
 block discarded – undo
627 615
 
628 616
 			if (self::$decoder->getElementStartTag(SYNC_PARTIAL)) {
629 617
 				$partial = true;
630
-			}
631
-			else {
618
+			} else {
632 619
 				$partial = false;
633 620
 			}
634 621
 
@@ -657,13 +644,11 @@  discard block
 block discarded – undo
657 644
 			// Load all collections - do not overwrite existing (received!), load states, check permissions and only load confirmed states!
658 645
 			try {
659 646
 				$sc->LoadAllCollections(false, true, true, true, true);
660
-			}
661
-			catch (StateInvalidException $siex) {
647
+			} catch (StateInvalidException $siex) {
662 648
 				$status = SYNC_STATUS_INVALIDSYNCKEY;
663 649
 				self::$topCollector->AnnounceInformation("StateNotFoundException", $this->singleFolder);
664 650
 				$this->saveMultiFolderInfo("exception", "StateNotFoundException");
665
-			}
666
-			catch (StatusException $stex) {
651
+			} catch (StatusException $stex) {
667 652
 				$status = SYNC_STATUS_FOLDERHIERARCHYCHANGED;
668 653
 				self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder);
669 654
 				$this->saveMultiFolderInfo("exception", "StatusException");
@@ -686,8 +671,7 @@  discard block
 block discarded – undo
686 671
 			if (!$sc->HasCollections()) {
687 672
 				$status = SYNC_STATUS_SYNCREQUESTINCOMPLETE;
688 673
 			}
689
-		}
690
-		elseif (isset($hbinterval)) {
674
+		} elseif (isset($hbinterval)) {
691 675
 			// load the hierarchy data - there are no permissions to verify so we just set it to false
692 676
 			if (!$sc->LoadCollection(false, true, false)) {
693 677
 				$status = SYNC_STATUS_FOLDERHIERARCHYCHANGED;
@@ -730,12 +714,10 @@  discard block
 block discarded – undo
730 714
 					// always check for changes
731 715
 					SLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): Entering Heartbeat mode"));
732 716
 					$foundchanges = $sc->CheckForChanges($sc->GetLifetime(), $interval);
733
-				}
734
-				catch (StatusException $stex) {
717
+				} catch (StatusException $stex) {
735 718
 					if ($stex->getCode() == SyncCollections::OBSOLETE_CONNECTION) {
736 719
 						$status = SYNC_COMMONSTATUS_SYNCSTATEVERSIONINVALID;
737
-					}
738
-					else {
720
+					} else {
739 721
 						$status = SYNC_STATUS_FOLDERHIERARCHYCHANGED;
740 722
 						self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder);
741 723
 						$this->saveMultiFolderInfo("exception", "StatusException");
@@ -752,8 +734,7 @@  discard block
 block discarded – undo
752 734
 					foreach ($sc as $folderid => $spa) {
753 735
 						if (self::$deviceManager->CheckHearbeatStateIntegrity($spa->GetFolderId(), $spa->GetUuid(), $spa->GetUuidCounter())) {
754 736
 							$status = SYNC_COMMONSTATUS_SYNCSTATEVERSIONINVALID;
755
-						}
756
-						else {
737
+						} else {
757 738
 							$sc->SaveCollection($spa);
758 739
 						}
759 740
 					}
@@ -774,8 +755,7 @@  discard block
 block discarded – undo
774 755
 						if ($changecount > 0 && $sc->WaitedForChanges() && self::$deviceManager->CheckHearbeatStateIntegrity($spa->GetFolderId(), $spa->GetUuid(), $spa->GetUuidCounter())) {
775 756
 							SLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): heartbeat: found %d changes in '%s' which was already synchronized. Heartbeat aborted!", $changecount, $folderid));
776 757
 							$status = SYNC_COMMONSTATUS_SYNCSTATEVERSIONINVALID;
777
-						}
778
-						else {
758
+						} else {
779 759
 							SLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): heartbeat: found %d changes in '%s'", $changecount, $folderid));
780 760
 						}
781 761
 					}
@@ -875,8 +855,7 @@  discard block
 block discarded – undo
875 855
 							if ($exporter === false) {
876 856
 								throw new StatusException(sprintf("HandleSync() could not get an exporter for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED);
877 857
 							}
878
-						}
879
-						catch (StatusException $stex) {
858
+						} catch (StatusException $stex) {
880 859
 							$status = $stex->getCode();
881 860
 						}
882 861
 
@@ -891,12 +870,10 @@  discard block
 block discarded – undo
891 870
 
892 871
 								$changecount = $exporter->GetChangeCount();
893 872
 							}
894
-						}
895
-						catch (StatusException $stex) {
873
+						} catch (StatusException $stex) {
896 874
 							if ($stex->getCode() === SYNC_FSSTATUS_CODEUNKNOWN && $spa->HasSyncKey()) {
897 875
 								$status = SYNC_STATUS_INVALIDSYNCKEY;
898
-							}
899
-							else {
876
+							} else {
900 877
 								$status = $stex->getCode();
901 878
 							}
902 879
 						}
@@ -910,8 +887,7 @@  discard block
 block discarded – undo
910 887
 							if ($changecount > 0) {
911 888
 								self::$deviceManager->SetFolderSyncStatus($folderid, DeviceManager::FLD_SYNC_INITIALIZED);
912 889
 							}
913
-						}
914
-						elseif ($status != SYNC_STATUS_SUCCESS) {
890
+						} elseif ($status != SYNC_STATUS_SUCCESS) {
915 891
 							self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder);
916 892
 							$this->saveMultiFolderInfo("exception", "StatusException");
917 893
 						}
@@ -1055,8 +1031,7 @@  discard block
 block discarded – undo
1055 1031
 		self::$encoder->startTag(SYNC_SYNCKEY);
1056 1032
 		if ($status == SYNC_STATUS_SUCCESS && $spa->HasNewSyncKey()) {
1057 1033
 			self::$encoder->content($spa->GetNewSyncKey());
1058
-		}
1059
-		else {
1034
+		} else {
1060 1035
 			self::$encoder->content($spa->GetSyncKey());
1061 1036
 		}
1062 1037
 		self::$encoder->endTag();
@@ -1150,8 +1125,7 @@  discard block
 block discarded – undo
1150 1125
 						SLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): message not to be streamed as requested by DeviceManager, id = %s", $id));
1151 1126
 						$fetchstatus = SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR;
1152 1127
 					}
1153
-				}
1154
-				catch (StatusException $stex) {
1128
+				} catch (StatusException $stex) {
1155 1129
 					$fetchstatus = $stex->getCode();
1156 1130
 				}
1157 1131
 
@@ -1168,8 +1142,7 @@  discard block
 block discarded – undo
1168 1142
 					self::$encoder->startTag(SYNC_DATA);
1169 1143
 					$data->Encode(self::$encoder);
1170 1144
 					self::$encoder->endTag();
1171
-				}
1172
-				else {
1145
+				} else {
1173 1146
 					SLog::Write(LOGLEVEL_WARN, sprintf("Unable to Fetch '%s'", $id));
1174 1147
 				}
1175 1148
 				self::$encoder->endTag();
@@ -1215,13 +1188,11 @@  discard block
 block discarded – undo
1215 1188
 					if ($n % 10 == 0) {
1216 1189
 						self::$topCollector->AnnounceInformation(sprintf("Streamed data of %d objects out of %d", $n, (($changecount > $windowSize) ? $windowSize : $changecount)));
1217 1190
 					}
1218
-				}
1219
-				catch (SyncObjectBrokenException $mbe) {
1191
+				} catch (SyncObjectBrokenException $mbe) {
1220 1192
 					$brokenSO = $mbe->GetSyncObject();
1221 1193
 					if (!$brokenSO) {
1222 1194
 						SLog::Write(LOGLEVEL_ERROR, sprintf("HandleSync(): Caught SyncObjectBrokenException but broken SyncObject not available. This should be fixed in the backend."));
1223
-					}
1224
-					else {
1195
+					} else {
1225 1196
 						if (!isset($brokenSO->id)) {
1226 1197
 							$brokenSO->id = "Unknown ID";
1227 1198
 							SLog::Write(LOGLEVEL_ERROR, sprintf("HandleSync(): Caught SyncObjectBrokenException but no ID of object set. This should be fixed in the backend."));
@@ -1285,13 +1256,11 @@  discard block
 block discarded – undo
1285 1256
 					$newFolderStatAfterExport = self::$backend->GetFolderStat(GSync::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()), $spa->GetBackendFolderId());
1286 1257
 					if ($newFolderStat === $newFolderStatAfterExport) {
1287 1258
 						$this->setFolderStat($spa, $newFolderStat);
1288
-					}
1289
-					else {
1259
+					} else {
1290 1260
 						SLog::Write(LOGLEVEL_DEBUG, "Sync() Folderstat differs after export, force another exporter run.");
1291 1261
 					}
1292 1262
 				}
1293
-			}
1294
-			else {
1263
+			} else {
1295 1264
 				self::$deviceManager->SetFolderSyncStatus($spa->GetFolderId(), DeviceManager::FLD_SYNC_INPROGRESS);
1296 1265
 			}
1297 1266
 		}
@@ -1316,15 +1285,13 @@  discard block
 block discarded – undo
1316 1285
 				elseif (!$spa->HasSyncKey()) {
1317 1286
 					$state = "";
1318 1287
 				}
1319
-			}
1320
-			catch (StatusException $stex) {
1288
+			} catch (StatusException $stex) {
1321 1289
 				$status = $stex->getCode();
1322 1290
 			}
1323 1291
 
1324 1292
 			if (isset($state) && $status == SYNC_STATUS_SUCCESS) {
1325 1293
 				self::$deviceManager->GetStateManager()->SetSyncState($spa->GetNewSyncKey(), $state, $spa->GetFolderId());
1326
-			}
1327
-			else {
1294
+			} else {
1328 1295
 				SLog::Write(LOGLEVEL_ERROR, sprintf("HandleSync(): error saving '%s' - no state information available", $spa->GetNewSyncKey()));
1329 1296
 			}
1330 1297
 		}
@@ -1365,13 +1332,11 @@  discard block
 block discarded – undo
1365 1332
 				if (!self::$backend->Setup(GSync::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) {
1366 1333
 					throw new StatusException(sprintf("HandleSync() could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED);
1367 1334
 				}
1368
-			}
1369
-			catch (StateNotFoundException $snfex) {
1335
+			} catch (StateNotFoundException $snfex) {
1370 1336
 				$status = SYNC_STATUS_INVALIDSYNCKEY;
1371 1337
 				self::$topCollector->AnnounceInformation("StateNotFoundException", $this->singleFolder);
1372 1338
 				$this->saveMultiFolderInfo("exception", "StateNotFoundException");
1373
-			}
1374
-			catch (StatusException $stex) {
1339
+			} catch (StatusException $stex) {
1375 1340
 				$status = $stex->getCode();
1376 1341
 				self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder);
1377 1342
 				$this->saveMultiFolderInfo("exception", "StateNotFoundException");
@@ -1411,8 +1376,7 @@  discard block
 block discarded – undo
1411 1376
 				// if there is a valid state obtained after importing changes in a previous loop, we use that state
1412 1377
 				if (isset($actiondata["failstate"], $actiondata["failstate"]["failedsyncstate"])) {
1413 1378
 					$this->importer->Config($actiondata["failstate"]["failedsyncstate"], $spa->GetConflict());
1414
-				}
1415
-				else {
1379
+				} else {
1416 1380
 					$this->importer->Config($sc->GetParameter($spa, "state"), $spa->GetConflict());
1417 1381
 				}
1418 1382
 
@@ -1420,8 +1384,7 @@  discard block
 block discarded – undo
1420 1384
 				$this->importer->ConfigContentParameters($spa->GetCPO());
1421 1385
 				$this->importer->LoadConflicts($spa->GetCPO(), $sc->GetParameter($spa, "state"));
1422 1386
 			}
1423
-		}
1424
-		catch (StatusException $stex) {
1387
+		} catch (StatusException $stex) {
1425 1388
 			$status = $stex->getCode();
1426 1389
 		}
1427 1390
 
@@ -1503,13 +1466,11 @@  discard block
 block discarded – undo
1503 1466
 						// check incoming message without logging WARN messages about errors
1504 1467
 						elseif (!($message instanceof SyncObject) || !$message->Check(true)) {
1505 1468
 							$actiondata["statusids"][$serverid] = SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR;
1506
-						}
1507
-						else {
1469
+						} else {
1508 1470
 							if (isset($message->read)) {
1509 1471
 								// Currently, 'read' is only sent by the PDA when it is ONLY setting the read flag.
1510 1472
 								$this->importer->ImportMessageReadFlag($serverid, $message->read);
1511
-							}
1512
-							elseif (!isset($message->flag)) {
1473
+							} elseif (!isset($message->flag)) {
1513 1474
 								$this->importer->ImportMessageChange($serverid, $message);
1514 1475
 							}
1515 1476
 
@@ -1521,8 +1482,7 @@  discard block
 block discarded – undo
1521 1482
 
1522 1483
 							$actiondata["statusids"][$serverid] = SYNC_STATUS_SUCCESS;
1523 1484
 						}
1524
-					}
1525
-					catch (StatusException $stex) {
1485
+					} catch (StatusException $stex) {
1526 1486
 						$actiondata["statusids"][$serverid] = $stex->getCode();
1527 1487
 					}
1528 1488
 					break;
@@ -1546,14 +1506,12 @@  discard block
 block discarded – undo
1546 1506
 						elseif (!($message instanceof SyncObject) || !$message->Check(true)) {
1547 1507
 							$actiondata["clientids"][$clientid] = false;
1548 1508
 							$actiondata["statusids"][$clientid] = SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR;
1549
-						}
1550
-						else {
1509
+						} else {
1551 1510
 							$actiondata["clientids"][$clientid] = false;
1552 1511
 							$actiondata["clientids"][$clientid] = $this->importer->ImportMessageChange(false, $message);
1553 1512
 							$actiondata["statusids"][$clientid] = SYNC_STATUS_SUCCESS;
1554 1513
 						}
1555
-					}
1556
-					catch (StatusException $stex) {
1514
+					} catch (StatusException $stex) {
1557 1515
 						$actiondata["statusids"][$clientid] = $stex->getCode();
1558 1516
 					}
1559 1517
 					break;
@@ -1568,8 +1526,7 @@  discard block
 block discarded – undo
1568 1526
 							SLog::Write(LOGLEVEL_DEBUG, "SMS sync are not supported. Ignoring message.");
1569 1527
 							// TODO we should delete the SMS
1570 1528
 							$actiondata["statusids"][$serverid] = SYNC_STATUS_SUCCESS;
1571
-						}
1572
-						else {
1529
+						} else {
1573 1530
 							// if message deletions are to be moved, move them
1574 1531
 							if ($spa->GetDeletesAsMoves()) {
1575 1532
 								$folderid = self::$backend->GetWasteBasket();
@@ -1587,8 +1544,7 @@  discard block
 block discarded – undo
1587 1544
 							$this->importer->ImportMessageDeletion($serverid);
1588 1545
 							$actiondata["statusids"][$serverid] = SYNC_STATUS_SUCCESS;
1589 1546
 						}
1590
-					}
1591
-					catch (StatusException $stex) {
1547
+					} catch (StatusException $stex) {
1592 1548
 						if ($stex->getCode() != SYNC_MOVEITEMSSTATUS_SUCCESS) {
1593 1549
 							$actiondata["statusids"][$serverid] = SYNC_STATUS_OBJECTNOTFOUND;
1594 1550
 						}
@@ -1636,11 +1592,9 @@  discard block
 block discarded – undo
1636 1592
 		}
1637 1593
 		if (isset($this->multiFolderInfo["outgoing"], $this->multiFolderInfo["queued"]) && $this->multiFolderInfo["outgoing"] > 0) {
1638 1594
 			$s .= sprintf(": Streamed %d out of %d", $this->multiFolderInfo["outgoing"], $this->multiFolderInfo["queued"]);
1639
-		}
1640
-		elseif (!isset($this->multiFolderInfo["outgoing"]) && !isset($this->multiFolderInfo["queued"])) {
1595
+		} elseif (!isset($this->multiFolderInfo["outgoing"]) && !isset($this->multiFolderInfo["queued"])) {
1641 1596
 			$s .= ": no changes";
1642
-		}
1643
-		else {
1597
+		} else {
1644 1598
 			if (isset($this->multiFolderInfo["outgoing"])) {
1645 1599
 				$s .= "/" . $this->multiFolderInfo["outgoing"] . " streamed";
1646 1600
 			}
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 					if (self::$decoder->getElementStartTag(SYNC_DELETESASMOVES)) {
207 207
 						$spa->SetDeletesAsMoves(true);
208 208
 						if (($dam = self::$decoder->getElementContent()) !== false) {
209
-							$spa->SetDeletesAsMoves((bool) $dam);
209
+							$spa->SetDeletesAsMoves((bool)$dam);
210 210
 							if (!self::$decoder->getElementEndTag()) {
211 211
 								return false;
212 212
 							}
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 					if (self::$decoder->getElementStartTag(SYNC_CONVERSATIONMODE)) {
250 250
 						$spa->SetConversationMode(true);
251 251
 						if (($conversationmode = self::$decoder->getElementContent()) !== false) {
252
-							$spa->SetConversationMode((bool) $conversationmode);
252
+							$spa->SetConversationMode((bool)$conversationmode);
253 253
 							if (!self::$decoder->getElementEndTag()) {
254 254
 								return false;
255 255
 							}
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 		}
1198 1198
 
1199 1199
 		// Stream outgoing changes
1200
-		if ($status == SYNC_STATUS_SUCCESS && $sc->GetParameter($spa, "getchanges") == true && $windowSize > 0 && (bool) $exporter) {
1200
+		if ($status == SYNC_STATUS_SUCCESS && $sc->GetParameter($spa, "getchanges") == true && $windowSize > 0 && (bool)$exporter) {
1201 1201
 			self::$topCollector->AnnounceInformation(sprintf("Streaming data of %d objects", (($changecount > $windowSize) ? $windowSize : $changecount)));
1202 1202
 
1203 1203
 			// Output message changes per folder
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
 			// $progress is not an array when exporting the last message
1251 1251
 			// so we get the number to display from the streamimporter if it's available
1252
-			if ((bool) $streamimporter) {
1252
+			if ((bool)$streamimporter) {
1253 1253
 				$n = $streamimporter->GetImportedMessages();
1254 1254
 			}
1255 1255
 
Please login to merge, or discard this patch.
lib/log/syslog.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -102,8 +102,7 @@  discard block
 block discarded – undo
102 102
 				if (isset($match[1])) {
103 103
 					return $this->GetProgramName() . '/' . $match[1];
104 104
 				}
105
-			}
106
-			elseif (basename($trace['file'], '.php') != 'slog') {
105
+			} elseif (basename($trace['file'], '.php') != 'slog') {
107 106
 				return $this->GetProgramName() . '/core';
108 107
 			}
109 108
 		}
@@ -162,8 +161,7 @@  discard block
 block discarded – undo
162 161
 		// when the users differ, we need to log both
163 162
 		if (strcasecmp($this->GetAuthUser(), $this->GetUser()) == 0) {
164 163
 			$log .= ' [' . $this->GetUser() . ']';
165
-		}
166
-		else {
164
+		} else {
167 165
 			$log .= ' [' . $this->GetAuthUser() . Request::IMPERSONATE_DELIM . $this->GetUser() . ']';
168 166
 		}
169 167
 		if ($loglevel >= LOGLEVEL_DEVICEID) {
@@ -195,8 +193,7 @@  discard block
 block discarded – undo
195 193
 				socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, $this->GetHost(), $this->GetPort());
196 194
 			}
197 195
 			socket_close($sock);
198
-		}
199
-		else {
196
+		} else {
200 197
 			openlog($this->GenerateProgramName(), LOG_PID, LOG_SYSLOG_FACILITY);
201 198
 			syslog(
202 199
 				$this->GetGsyncLogLevelToSyslogLogLevel($loglevel),
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 	 */
53 53
 	public function SetPort($value) {
54 54
 		if (is_numeric($value)) {
55
-			$this->port = (int) $value;
55
+			$this->port = (int)$value;
56 56
 		}
57 57
 	}
58 58
 
Please login to merge, or discard this patch.