Passed
Branch master (ff9d34)
by Mike
09:14
created
lib/core/streamer.php 1 patch
Braces   +97 added lines, -94 removed lines patch added patch discarded remove patch
@@ -77,14 +77,11 @@  discard block
 block discarded – undo
77 77
                     $map = $this->mapping[$entity[EN_TAG]];
78 78
                     if (isset($map[self::STREAMER_ARRAY])) {
79 79
                         $this->{$map[self::STREAMER_VAR]} = array();
80
-                    }
81
-                    else if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) {
80
+                    } else if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) {
82 81
                         $this->{$map[self::STREAMER_VAR]} = "1";
83
-                    }
84
-                    else if(!isset($map[self::STREAMER_TYPE])) {
82
+                    } else if(!isset($map[self::STREAMER_TYPE])) {
85 83
                         $this->{$map[self::STREAMER_VAR]} = "";
86
-                    }
87
-                    else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES ) {
84
+                    } else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES ) {
88 85
                         $this->{$map[self::STREAMER_VAR]} = "";
89 86
                     }
90 87
                     continue;
@@ -94,8 +91,7 @@  discard block
 block discarded – undo
94 91
                     // This tag shouldn't be here, abort
95 92
                     ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("Tag '%s' unexpected in type XML type '%s'", $entity[EN_TAG], get_class($this)));
96 93
                     return false;
97
-                }
98
-                else {
94
+                } else {
99 95
                     $map = $this->mapping[$entity[EN_TAG]];
100 96
 
101 97
                     // Handle an array
@@ -104,25 +100,28 @@  discard block
 block discarded – undo
104 100
                         while(WBXMLDecoder::InWhile("decodeArray")) {
105 101
                             //do not get start tag for an array without a container
106 102
                             if (!(isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER)) {
107
-                                if(!$decoder->getElementStartTag($map[self::STREAMER_ARRAY]))
108
-                                    break;
103
+                                if(!$decoder->getElementStartTag($map[self::STREAMER_ARRAY])) {
104
+                                                                    break;
105
+                                }
109 106
                             }
110 107
                             if(isset($map[self::STREAMER_TYPE])) {
111 108
                                 $decoded = new $map[self::STREAMER_TYPE];
112 109
 
113 110
                                 $decoded->Decode($decoder);
114
-                            }
115
-                            else {
111
+                            } else {
116 112
                                 $decoded = $decoder->getElementContent();
117 113
                             }
118 114
 
119
-                            if(!isset($this->{$map[self::STREAMER_VAR]}))
120
-                                $this->{$map[self::STREAMER_VAR]} = array($decoded);
121
-                            else
122
-                                array_push($this->{$map[self::STREAMER_VAR]}, $decoded);
115
+                            if(!isset($this->{$map[self::STREAMER_VAR]})) {
116
+                                                            $this->{$map[self::STREAMER_VAR]} = array($decoded);
117
+                            } else {
118
+                                                            array_push($this->{$map[self::STREAMER_VAR]}, $decoded);
119
+                            }
123 120
 
124
-                            if(!$decoder->getElementEndTag()) //end tag of a container element
121
+                            if(!$decoder->getElementEndTag()) {
122
+                                //end tag of a container element
125 123
                                 return false;
124
+                            }
126 125
 
127 126
                             if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER) {
128 127
                                 $e = $decoder->peek();
@@ -131,47 +130,52 @@  discard block
 block discarded – undo
131 130
                                     continue 2;
132 131
                                 }
133 132
                                 //break on end tag because no container elements block end is reached
134
-                                if ($e[EN_TYPE] == EN_TYPE_ENDTAG)
135
-                                    break;
136
-                                if (empty($e))
137
-                                    break;
133
+                                if ($e[EN_TYPE] == EN_TYPE_ENDTAG) {
134
+                                                                    break;
135
+                                }
136
+                                if (empty($e)) {
137
+                                                                    break;
138
+                                }
138 139
                             }
139 140
                         }
140 141
                         //do not get end tag for an array without a container
141 142
                         if (!(isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER)) {
142
-                            if(!$decoder->getElementEndTag()) //end tag of container
143
+                            if(!$decoder->getElementEndTag()) {
144
+                                //end tag of container
143 145
                                 return false;
146
+                            }
144 147
                         }
145
-                    }
146
-                    else { // Handle single value
148
+                    } else { // Handle single value
147 149
                         if(isset($map[self::STREAMER_TYPE])) {
148 150
                             // Complex type, decode recursively
149 151
                             if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES) {
150 152
                                 $decoded = $this->parseDate($decoder->getElementContent());
151
-                                if(!$decoder->getElementEndTag())
152
-                                    return false;
153
-                            }
154
-                            else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) {
153
+                                if(!$decoder->getElementEndTag()) {
154
+                                                                    return false;
155
+                                }
156
+                            } else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) {
155 157
                                 $decoded = hex2bin($decoder->getElementContent());
156
-                                if(!$decoder->getElementEndTag())
157
-                                    return false;
158
+                                if(!$decoder->getElementEndTag()) {
159
+                                                                    return false;
160
+                                }
158 161
                             }
159 162
                             // explode comma or semicolon strings into arrays
160 163
                             else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED) {
161 164
                                 $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED)?", ":"; ";
162 165
                                 $decoded = explode($glue, $decoder->getElementContent());
163
-                                if(!$decoder->getElementEndTag())
164
-                                    return false;
165
-                            }
166
-                            else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) {
166
+                                if(!$decoder->getElementEndTag()) {
167
+                                                                    return false;
168
+                                }
169
+                            } else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) {
167 170
                                 $decoded = StringStreamWrapper::Open($decoder->getElementContent());
168
-                                if(!$decoder->getElementEndTag())
169
-                                    return false;
170
-                            }
171
-                            else {
171
+                                if(!$decoder->getElementEndTag()) {
172
+                                                                    return false;
173
+                                }
174
+                            } else {
172 175
                                 $subdecoder = new $map[self::STREAMER_TYPE]();
173
-                                if($subdecoder->Decode($decoder) === false)
174
-                                    return false;
176
+                                if($subdecoder->Decode($decoder) === false) {
177
+                                                                    return false;
178
+                                }
175 179
 
176 180
                                 $decoded = $subdecoder;
177 181
 
@@ -180,8 +184,7 @@  discard block
 block discarded – undo
180 184
                                     return false;
181 185
                                 }
182 186
                             }
183
-                        }
184
-                        else {
187
+                        } else {
185 188
                             // Simple type, just get content
186 189
                             $decoded = $decoder->getElementContent();
187 190
 
@@ -200,12 +203,10 @@  discard block
 block discarded – undo
200 203
                         $this->{$map[self::STREAMER_VAR]} = $decoded;
201 204
                     }
202 205
                 }
203
-            }
204
-            else if($entity[EN_TYPE] == EN_TYPE_ENDTAG) {
206
+            } else if($entity[EN_TYPE] == EN_TYPE_ENDTAG) {
205 207
                 $decoder->ungetElement($entity);
206 208
                 break;
207
-            }
208
-            else {
209
+            } else {
209 210
                 ZLog::Write(LOGLEVEL_WBXMLSTACK, "Unexpected content in type");
210 211
                 break;
211 212
             }
@@ -232,30 +233,30 @@  discard block
 block discarded – undo
232 233
                         $res = $this->{$map[self::STREAMER_VAR]}->Encode($encoder);
233 234
                         $encoder->endTag();
234 235
                         // nothing was streamed in previous encode but it should be streamed empty anyway
235
-                        if (!$res && isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY)
236
-                            $encoder->startTag($tag, false, true);
236
+                        if (!$res && isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) {
237
+                                                    $encoder->startTag($tag, false, true);
238
+                        }
239
+                    } else {
240
+                                            ZLog::Write(LOGLEVEL_ERROR, sprintf("Streamer->Encode(): parameter '%s' of object %s is not of type Streamer", $map[self::STREAMER_VAR], get_class($this)));
237 241
                     }
238
-                    else
239
-                        ZLog::Write(LOGLEVEL_ERROR, sprintf("Streamer->Encode(): parameter '%s' of object %s is not of type Streamer", $map[self::STREAMER_VAR], get_class($this)));
240 242
                 }
241 243
                 // Array of objects
242 244
                 else if(isset($map[self::STREAMER_ARRAY])) {
243 245
                     if (empty($this->{$map[self::STREAMER_VAR]}) && isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) {
244 246
                         $encoder->startTag($tag, false, true);
245
-                    }
246
-                    else {
247
+                    } else {
247 248
                         // Outputs array container (eg Attachments)
248 249
                         // Do not output start and end tag when type is STREAMER_TYPE_NO_CONTAINER
249
-                        if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER)
250
-                            $encoder->startTag($tag);
250
+                        if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER) {
251
+                                                    $encoder->startTag($tag);
252
+                        }
251 253
 
252 254
                         foreach ($this->{$map[self::STREAMER_VAR]} as $element) {
253 255
                             if(is_object($element)) {
254 256
                                 $encoder->startTag($map[self::STREAMER_ARRAY]); // Outputs object container (eg Attachment)
255 257
                                 $element->Encode($encoder);
256 258
                                 $encoder->endTag();
257
-                            }
258
-                            else {
259
+                            } else {
259 260
                                 if(strlen($element) == 0)
260 261
                                       // Do not output empty items. Not sure if we should output an empty tag with $encoder->startTag($map[self::STREAMER_ARRAY], false, true);
261 262
                                       ;
@@ -268,11 +269,11 @@  discard block
 block discarded – undo
268 269
                             }
269 270
                         }
270 271
 
271
-                        if  (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER)
272
-                            $encoder->endTag();
272
+                        if  (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER) {
273
+                                                    $encoder->endTag();
274
+                        }
273 275
                     }
274
-                }
275
-                else {
276
+                } else {
276 277
                     if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_IGNORE) {
277 278
                         continue;
278 279
                     }
@@ -288,25 +289,26 @@  discard block
 block discarded – undo
288 289
                     // Simple type
289 290
                     if(!isset($map[self::STREAMER_TYPE]) && strlen($this->{$map[self::STREAMER_VAR]}) == 0) {
290 291
                         // send empty tags
291
-                        if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY)
292
-                            $encoder->startTag($tag, false, true);
292
+                        if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) {
293
+                                                    $encoder->startTag($tag, false, true);
294
+                        }
293 295
 
294 296
                         // Do not output empty items. See above: $encoder->startTag($tag, false, true);
295 297
                         continue;
296
-                    } else
297
-                        $encoder->startTag($tag);
298
+                    } else {
299
+                                            $encoder->startTag($tag);
300
+                    }
298 301
 
299 302
                     if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES)) {
300
-                        if($this->{$map[self::STREAMER_VAR]} != 0) // don't output 1-1-1970
303
+                        if($this->{$map[self::STREAMER_VAR]} != 0) {
304
+                            // don't output 1-1-1970
301 305
                             $encoder->content($this->formatDate($this->{$map[self::STREAMER_VAR]}, $map[self::STREAMER_TYPE]));
302
-                    }
303
-                    else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) {
306
+                        }
307
+                    } else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) {
304 308
                         $encoder->content(strtoupper(bin2hex($this->{$map[self::STREAMER_VAR]})));
305
-                    }
306
-                    else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) {
309
+                    } else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) {
307 310
                         $encoder->contentStream($this->{$map[self::STREAMER_VAR]}, false);
308
-                    }
309
-                    else if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASBASE64 || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM)) {
311
+                    } else if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASBASE64 || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM)) {
310 312
                         $encoder->contentStream($this->{$map[self::STREAMER_VAR]}, true);
311 313
                     }
312 314
                     // implode comma or semicolon arrays into a string
@@ -314,8 +316,7 @@  discard block
 block discarded – undo
314 316
                         ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED)) {
315 317
                         $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED)?", ":"; ";
316 318
                         $encoder->content(implode($glue, $this->{$map[self::STREAMER_VAR]}));
317
-                    }
318
-                    else {
319
+                    } else {
319 320
                         $encoder->content($this->{$map[self::STREAMER_VAR]});
320 321
                     }
321 322
                     $encoder->endTag();
@@ -324,8 +325,9 @@  discard block
 block discarded – undo
324 325
             }
325 326
         }
326 327
         // Output our own content
327
-        if(isset($this->content))
328
-            $encoder->content($this->content);
328
+        if(isset($this->content)) {
329
+                    $encoder->content($this->content);
330
+        }
329 331
 
330 332
         return $streamed;
331 333
     }
@@ -341,27 +343,22 @@  discard block
 block discarded – undo
341 343
             if (isset($this->{$v[self::STREAMER_VAR]})) {
342 344
                 if (is_object($this->{$v[self::STREAMER_VAR]}) && method_exists($this->{$v[self::STREAMER_VAR]}, "StripData") ) {
343 345
                     $this->{$v[self::STREAMER_VAR]}->StripData($flags);
344
-                }
345
-                else if (isset($v[self::STREAMER_ARRAY]) && !empty($this->{$v[self::STREAMER_VAR]})) {
346
+                } else if (isset($v[self::STREAMER_ARRAY]) && !empty($this->{$v[self::STREAMER_VAR]})) {
346 347
                     foreach ($this->{$v[self::STREAMER_VAR]} as $element) {
347 348
                         if (is_object($element) && method_exists($element, "StripData") ) {
348 349
                             $element->StripData($flags);
349
-                        }
350
-                        elseif ($flags === Streamer::STRIP_PRIVATE_DATA && isset($v[self::STREAMER_PRIVATE])) {
350
+                        } elseif ($flags === Streamer::STRIP_PRIVATE_DATA && isset($v[self::STREAMER_PRIVATE])) {
351 351
                             if ($v[self::STREAMER_PRIVATE] !== true) {
352 352
                                 $this->{$v[self::STREAMER_VAR]} = $v[self::STREAMER_PRIVATE];
353
-                            }
354
-                            else {
353
+                            } else {
355 354
                                 unset($this->{$v[self::STREAMER_VAR]});
356 355
                             }
357 356
                         }
358 357
                     }
359
-                }
360
-                elseif ($flags === Streamer::STRIP_PRIVATE_DATA && isset($v[self::STREAMER_PRIVATE])) {
358
+                } elseif ($flags === Streamer::STRIP_PRIVATE_DATA && isset($v[self::STREAMER_PRIVATE])) {
361 359
                     if ($v[self::STREAMER_PRIVATE] !== true) {
362 360
                         $this->{$v[self::STREAMER_VAR]} = $v[self::STREAMER_PRIVATE];
363
-                    }
364
-                    else {
361
+                    } else {
365 362
                         unset($this->{$v[self::STREAMER_VAR]});
366 363
                     }
367 364
                 }
@@ -423,8 +420,7 @@  discard block
 block discarded – undo
423 420
                 ZLog::Write(LOGLEVEL_DEBUG, sprintf("Streamer->jsonDeserialize(): top class '%s'", $v->gsSyncStateClass));
424 421
                 $this->$k = new $v->gsSyncStateClass;
425 422
                 $this->$k->jsonDeserialize($v);
426
-            }
427
-            else {
423
+            } else {
428 424
                 $this->$k = $v;
429 425
             }
430 426
         }
@@ -448,10 +444,11 @@  discard block
 block discarded – undo
448 444
      * @return string
449 445
      */
450 446
     private function formatDate($ts, $type) {
451
-        if($type == self::STREAMER_TYPE_DATE)
452
-            return gmstrftime("%Y%m%dT%H%M%SZ", $ts);
453
-        else if($type == self::STREAMER_TYPE_DATE_DASHES)
454
-            return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts);
447
+        if($type == self::STREAMER_TYPE_DATE) {
448
+                    return gmstrftime("%Y%m%dT%H%M%SZ", $ts);
449
+        } else if($type == self::STREAMER_TYPE_DATE_DASHES) {
450
+                    return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts);
451
+        }
455 452
         // fallback to dashes (should never be reached)
456 453
         return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts);
457 454
     }
@@ -473,9 +470,15 @@  discard block
 block discarded – undo
473 470
                 $matches[5] = $matches[6] = $matches[7] = 0;
474 471
             }
475 472
 
476
-            if (!isset($matches[5])) $matches[5] = 0;
477
-            if (!isset($matches[6])) $matches[6] = 0;
478
-            if (!isset($matches[7])) $matches[7] = 0;
473
+            if (!isset($matches[5])) {
474
+                $matches[5] = 0;
475
+            }
476
+            if (!isset($matches[6])) {
477
+                $matches[6] = 0;
478
+            }
479
+            if (!isset($matches[7])) {
480
+                $matches[7] = 0;
481
+            }
479 482
 
480 483
             return gmmktime($matches[5], $matches[6], $matches[7], $matches[2], $matches[3], $matches[1]);
481 484
         }
Please login to merge, or discard this patch.
lib/core/loopdetection.php 1 patch
Braces   +77 added lines, -67 removed lines patch added patch discarded remove patch
@@ -71,8 +71,9 @@  discard block
 block discarded – undo
71 71
      * @return string
72 72
      */
73 73
     public static function GetProcessIdentifier() {
74
-        if (!isset(self::$processident))
75
-            self::$processident = sprintf('%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff));
74
+        if (!isset(self::$processident)) {
75
+                    self::$processident = sprintf('%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff));
76
+        }
76 77
 
77 78
         return self::$processident;
78 79
     }
@@ -107,8 +108,9 @@  discard block
 block discarded – undo
107 108
         // generate entry if not already there
108 109
         self::GetProcessEntry();
109 110
 
110
-        if (!isset(self::$processentry['stat']))
111
-            self::$processentry['stat'] = array();
111
+        if (!isset(self::$processentry['stat'])) {
112
+                    self::$processentry['stat'] = array();
113
+        }
112 114
 
113 115
         self::$processentry['stat'][get_class($exception)] = $exception->getCode();
114 116
 
@@ -130,11 +132,13 @@  discard block
 block discarded – undo
130 132
         // generate entry if not already there
131 133
         self::GetProcessEntry();
132 134
 
133
-        if ($folderid === false)
134
-            $folderid = "hierarchy";
135
+        if ($folderid === false) {
136
+                    $folderid = "hierarchy";
137
+        }
135 138
 
136
-        if (!isset(self::$processentry['stat']))
137
-            self::$processentry['stat'] = array();
139
+        if (!isset(self::$processentry['stat'])) {
140
+                    self::$processentry['stat'] = array();
141
+        }
138 142
 
139 143
         self::$processentry['stat'][$folderid] = $status;
140 144
 
@@ -257,8 +261,9 @@  discard block
 block discarded – undo
257 261
                             ($se['cc'] == ZPush::COMMAND_SYNC && $value == SYNC_STATUS_SUCCESS) ) {
258 262
                             continue;
259 263
                         }
260
-                        if (!isset($seenFailed[$key]))
261
-                            $seenFailed[$key] = 0;
264
+                        if (!isset($seenFailed[$key])) {
265
+                                                    $seenFailed[$key] = 0;
266
+                        }
262 267
                         $seenFailed[$key]++;
263 268
                         ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): seen command with Exception or folderid '%s' and code '%s'", $key, $value ));
264 269
                     }
@@ -269,11 +274,11 @@  discard block
 block discarded – undo
269 274
                     if (isset($se['stat']) && isset($se['stat']['hierarchy']) && $se['stat']['hierarchy'] == SYNC_FSSTATUS_SYNCKEYERROR) {
270 275
                         ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): a full FolderReSync was already requested. Resetting fail counter.");
271 276
                         $seenFailed = array();
272
-                    }
273
-                    else {
277
+                    } else {
274 278
                         $seenFolderSync = true;
275
-                        if (!empty($seenFailed))
276
-                            ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): seen FolderSync after other failing command");
279
+                        if (!empty($seenFailed)) {
280
+                                                    ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): seen FolderSync after other failing command");
281
+                        }
277 282
                     }
278 283
                 }
279 284
             }
@@ -281,8 +286,9 @@  discard block
 block discarded – undo
281 286
 
282 287
         $filtered = array();
283 288
         foreach ($seenFailed as $k => $count) {
284
-            if ($count>1)
285
-                $filtered[] = $k;
289
+            if ($count>1) {
290
+                            $filtered[] = $k;
291
+            }
286 292
         }
287 293
 
288 294
         if ($seenFolderSync && !empty($filtered)) {
@@ -360,18 +366,19 @@  discard block
 block discarded – undo
360 366
             foreach ($stack as $entry) {
361 367
                 if ($entry['id'] != $updateentry['id']) {
362 368
                     $nstack[] = $entry;
363
-                }
364
-                else {
369
+                } else {
365 370
                     $nstack[] = $updateentry;
366 371
                     $found = true;
367 372
                 }
368 373
             }
369 374
 
370
-            if (!$found)
371
-                $nstack[] = $updateentry;
375
+            if (!$found) {
376
+                            $nstack[] = $updateentry;
377
+            }
372 378
 
373
-            if (count($nstack) > 10)
374
-                $nstack = array_slice($nstack, -10, 10);
379
+            if (count($nstack) > 10) {
380
+                            $nstack = array_slice($nstack, -10, 10);
381
+            }
375 382
 
376 383
             // update loop data
377 384
             $ok = $this->setDeviceUserData($this->type, $nstack, parent::$devid, parent::$user, self::INTERPROCESSLD, $doCas="replace", $stackRaw);
@@ -418,8 +425,9 @@  discard block
 block discarded – undo
418 425
      * @return boolean
419 426
      */
420 427
     public function SetBrokenMessage($folderid, $id) {
421
-        if ($folderid == false || !isset($this->broken_message_uuid) || !isset($this->broken_message_counter) || $this->broken_message_uuid == false || $this->broken_message_counter == false)
422
-            return false;
428
+        if ($folderid == false || !isset($this->broken_message_uuid) || !isset($this->broken_message_counter) || $this->broken_message_uuid == false || $this->broken_message_counter == false) {
429
+                    return false;
430
+        }
423 431
 
424 432
         $ok = false;
425 433
         $brokenkey = self::BROKENMSGS ."-". $folderid;
@@ -456,8 +464,9 @@  discard block
 block discarded – undo
456 464
      * @return array
457 465
      */
458 466
     public function GetSyncedButBeforeIgnoredMessages($folderid) {
459
-        if ($folderid == false || !isset($this->broken_message_uuid) || !isset($this->broken_message_counter) || $this->broken_message_uuid == false || $this->broken_message_counter == false)
460
-            return array();
467
+        if ($folderid == false || !isset($this->broken_message_uuid) || !isset($this->broken_message_counter) || $this->broken_message_uuid == false || $this->broken_message_counter == false) {
468
+                    return array();
469
+        }
461 470
 
462 471
         $brokenkey = self::BROKENMSGS ."-". $folderid;
463 472
         $removeIds = array();
@@ -473,8 +482,7 @@  discard block
 block discarded – undo
473 482
 
474 483
             if (empty($brokenmsgs)) {
475 484
                 break;
476
-            }
477
-            else {
485
+            } else {
478 486
                 foreach ($brokenmsgs as $id => $data) {
479 487
                     // previously broken message was successfully synced!
480 488
                     if ($data['uuid'] == $this->broken_message_uuid && $data['counter'] < $this->broken_message_counter) {
@@ -498,8 +506,7 @@  discard block
 block discarded – undo
498 506
                     $this->delDeviceUserData($this->type, parent::$devid, parent::$user, $brokenkey);
499 507
                     ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->GetSyncedButBeforeIgnoredMessages('%s'): removed folder from tracking of ignored messages", $folderid));
500 508
                     break;
501
-                }
502
-                else {
509
+                } else {
503 510
                     // update data
504 511
                     $ok = $this->setDeviceUserData($this->type, $brokenmsgs, parent::$devid, parent::$user, $brokenkey, $doCas="replace", $brokenmsgsRaw);
505 512
                     if (!$ok) {
@@ -585,8 +592,7 @@  discard block
 block discarded – undo
585 592
             if (!isset($current["uuid"]) || $current["uuid"] != $uuid) {
586 593
                 ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IsSyncStateObsolete(): yes, uuid changed or not set");
587 594
                 $obsolete = true;
588
-            }
589
-            else {
595
+            } else {
590 596
                 ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IsSyncStateObsolete(): check folderid: '%s' uuid '%s' counter: %d - last counter: %d with %d queued",
591 597
                         $folderid, $uuid, $counter, $current["count"], $current["queued"]));
592 598
 
@@ -600,8 +606,7 @@  discard block
 block discarded – undo
600 606
                     $obsolete = true;
601 607
                 }
602 608
             }
603
-        }
604
-        else {
609
+        } else {
605 610
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IsSyncStateObsolete(): check folderid: '%s' uuid '%s' counter: %d - no data found: not obsolete", $folderid, $uuid, $counter));
606 611
         }
607 612
 
@@ -661,8 +666,9 @@  discard block
 block discarded – undo
661 666
             list($current, $currentRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $folderid, true);
662 667
 
663 668
             // completely new/unknown UUID
664
-            if (empty($current))
665
-                $current = array("uuid" => $uuid, "count" => $counter-1, "queued" => $queuedMessages);
669
+            if (empty($current)) {
670
+                            $current = array("uuid" => $uuid, "count" => $counter-1, "queued" => $queuedMessages);
671
+            }
666 672
 
667 673
             // old UUID in cache - the device requested a new state!!
668 674
             if (isset($current['uuid']) && $current['uuid'] != $uuid ) {
@@ -675,8 +681,7 @@  discard block
 block discarded – undo
675 681
                     ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): UUID changed and while items where sent to device - forcing loop mode");
676 682
                     $loop = true; // force loop mode
677 683
                     $current['queued'] = $queuedMessages;
678
-                }
679
-                else {
684
+                } else {
680 685
                     $current['queued'] = 0;
681 686
                 }
682 687
 
@@ -700,8 +705,9 @@  discard block
 block discarded – undo
700 705
                     // case 1.1
701 706
                     $current['count'] = $counter;
702 707
                     $current['queued'] = $queuedMessages;
703
-                    if (isset($current["usage"]) && $current["usage"] < $current['count'])
704
-                        unset($current["usage"]);
708
+                    if (isset($current["usage"]) && $current["usage"] < $current['count']) {
709
+                                            unset($current["usage"]);
710
+                    }
705 711
 
706 712
                     // case 1.2
707 713
                     if (isset($current['maxCount'])) {
@@ -729,8 +735,9 @@  discard block
 block discarded – undo
729 735
                 // case 2 - same counter, but there were no changes before and are there now
730 736
                 else if ($current['count'] == $counter && $current['queued'] == 0 && $queuedMessages > 0) {
731 737
                     $current['queued'] = $queuedMessages;
732
-                    if (isset($current["usage"]) && $current["usage"] < $current['count'])
733
-                        unset($current["usage"]);
738
+                    if (isset($current["usage"]) && $current["usage"] < $current['count']) {
739
+                                            unset($current["usage"]);
740
+                    }
734 741
                 }
735 742
 
736 743
                 // case 3 - same counter, changes sent before, hanging loop and ignoring
@@ -746,8 +753,7 @@  discard block
 block discarded – undo
746 753
                             // return suggested new window size
747 754
                             $current['windowLimit'] = 25;
748 755
                             $loop = $current['windowLimit'];
749
-                        }
750
-                        else {
756
+                        } else {
751 757
                             // case 3.1) we have just encountered a loop!
752 758
                             ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): case 3.1 detected - loop detected, init loop mode");
753 759
                             if (isset($current['windowLimit'])) {
@@ -759,8 +765,7 @@  discard block
 block discarded – undo
759 765
                             $current['maxCount'] = $counter + (($maxItems < $queuedMessages) ? $maxItems : $queuedMessages);
760 766
                             $loop = true;   // loop mode!!
761 767
                         }
762
-                    }
763
-                    else if ($queuedMessages == 0) {
768
+                    } else if ($queuedMessages == 0) {
764 769
                         // case 3.2) there was a loop before but now the changes are GONE
765 770
                         ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): case 3.2 detected - changes gone - clearing loop data");
766 771
                         $current['queued'] = 0;
@@ -769,8 +774,7 @@  discard block
 block discarded – undo
769 774
                         unset($current['maxCount']);
770 775
                         unset($current['potential']);
771 776
                         unset($current['windowLimit']);
772
-                    }
773
-                    else {
777
+                    } else {
774 778
                         // case 3.3) still looping the same message! Increase counter
775 779
                         ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): case 3.3 detected - in loop mode, increase loop counter");
776 780
                         $current['loopcount']++;
@@ -786,8 +790,9 @@  discard block
 block discarded – undo
786 790
                 }
787 791
 
788 792
             }
789
-            if (isset($current['loopcount']))
790
-                ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->Detect(): loop data: loopcount(%d), maxCount(%d), queued(%d), ignored(%s)", $current['loopcount'], $current['maxCount'], $current['queued'], (isset($current['ignored'])?$current['ignored']:'false')));
793
+            if (isset($current['loopcount'])) {
794
+                            ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->Detect(): loop data: loopcount(%d), maxCount(%d), queued(%d), ignored(%s)", $current['loopcount'], $current['maxCount'], $current['queued'], (isset($current['ignored'])?$current['ignored']:'false')));
795
+            }
791 796
 
792 797
             // update loop data
793 798
             $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas="replace", $currentRaw);
@@ -824,11 +829,13 @@  discard block
 block discarded – undo
824 829
 
825 830
         $potentialBroken = false;
826 831
         $realBroken = false;
827
-        if (Request::GetCommandCode() == ZPush::COMMAND_SYNC && $this->ignore_messageid !== false)
828
-            $potentialBroken = true;
832
+        if (Request::GetCommandCode() == ZPush::COMMAND_SYNC && $this->ignore_messageid !== false) {
833
+                    $potentialBroken = true;
834
+        }
829 835
 
830
-        if ($messageid !== false && $this->ignore_messageid == $messageid)
831
-            $realBroken = true;
836
+        if ($messageid !== false && $this->ignore_messageid == $messageid) {
837
+                    $realBroken = true;
838
+        }
832 839
 
833 840
         // this call is just to know what should be happening
834 841
         // no further actions necessary
@@ -892,8 +899,9 @@  discard block
 block discarded – undo
892 899
             }
893 900
         }
894 901
 
895
-        if ($realBroken)
896
-            ZPush::GetTopCollector()->AnnounceInformation("Broken message ignored", true);
902
+        if ($realBroken) {
903
+                    ZPush::GetTopCollector()->AnnounceInformation("Broken message ignored", true);
904
+        }
897 905
 
898 906
         return $realBroken;
899 907
     }
@@ -915,19 +923,20 @@  discard block
 block discarded – undo
915 923
         if ($this->blockMutex()) {
916 924
             $loopdata = ($this->hasData()) ? $this->getData() : array();
917 925
 
918
-            if ($user == false && $devid == false)
919
-                $loopdata = array();
920
-            elseif ($user == false && $devid != false)
921
-                $loopdata[$devid] = array();
922
-            elseif ($user != false && $devid != false)
923
-                $loopdata[$devid][$user] = array();
924
-            elseif ($user != false && $devid == false) {
926
+            if ($user == false && $devid == false) {
927
+                            $loopdata = array();
928
+            } elseif ($user == false && $devid != false) {
929
+                            $loopdata[$devid] = array();
930
+            } elseif ($user != false && $devid != false) {
931
+                            $loopdata[$devid][$user] = array();
932
+            } elseif ($user != false && $devid == false) {
925 933
                 ZLog::Write(LOGLEVEL_WARN, sprintf("Not possible to reset loop detection data for user '%s' without a specifying a device id", $user));
926 934
                 $stat = false;
927 935
             }
928 936
 
929
-            if ($stat)
930
-                $ok = $this->setData($loopdata);
937
+            if ($stat) {
938
+                            $ok = $this->setData($loopdata);
939
+            }
931 940
 
932 941
             $this->releaseMutex();
933 942
         }
@@ -955,8 +964,9 @@  discard block
 block discarded – undo
955 964
             $this->releaseMutex();
956 965
         }
957 966
         // end exclusive block
958
-        if (isset($loopdata) && isset($loopdata[$devid]) && isset($loopdata[$devid][$user]))
959
-            return $loopdata[$devid][$user];
967
+        if (isset($loopdata) && isset($loopdata[$devid]) && isset($loopdata[$devid][$user])) {
968
+                    return $loopdata[$devid][$user];
969
+        }
960 970
 
961 971
         return false;
962 972
     }
Please login to merge, or discard this patch.
lib/core/topcollector.php 1 patch
Braces   +16 added lines, -11 removed lines patch added patch discarded remove patch
@@ -76,10 +76,13 @@  discard block
 block discarded – undo
76 76
         $wasEnabled = ($this->hasData(self::ENABLEDAT)) ? $this->getData(self::ENABLEDAT) : false;
77 77
 
78 78
         $time = time();
79
-        if ($stop === true) $time = 0;
79
+        if ($stop === true) {
80
+            $time = 0;
81
+        }
80 82
 
81
-        if (! $this->setData($time, self::ENABLEDAT))
82
-            return false;
83
+        if (! $this->setData($time, self::ENABLEDAT)) {
84
+                    return false;
85
+        }
83 86
 
84 87
         return $wasEnabled;
85 88
     }
@@ -104,12 +107,14 @@  discard block
 block discarded – undo
104 107
 
105 108
         if ($terminating) {
106 109
             $this->latest["ended"] = time();
107
-            foreach ($this->preserved as $p)
108
-                $this->latest["addinfo"] .= " : ".$p;
110
+            foreach ($this->preserved as $p) {
111
+                            $this->latest["addinfo"] .= " : ".$p;
112
+            }
109 113
         }
110 114
 
111
-        if ($preserve)
112
-            $this->preserved[] = $addinfo;
115
+        if ($preserve) {
116
+                    $this->preserved[] = $addinfo;
117
+        }
113 118
 
114 119
         if ($this->isEnabled()) {
115 120
             // use the pid as subkey
@@ -142,13 +147,13 @@  discard block
 block discarded – undo
142 147
      */
143 148
     public function ClearLatest($all = false) {
144 149
         // it's ok when doing this every 10 sec
145
-        if ($all == false && time() % 10 != 0 )
146
-            return true;
150
+        if ($all == false && time() % 10 != 0 ) {
151
+                    return true;
152
+        }
147 153
 
148 154
         if ($all == true) {
149 155
             $this->getRedis()->delKey(self::TOPDATA);
150
-        }
151
-        else {
156
+        } else {
152 157
             foreach ($this->getRawDeviceUserData(self::TOPDATA) as $compKey => $rawline) {
153 158
                 $line = json_decode($rawline, true);
154 159
                 // remove everything which terminated for 20 secs or is not updated for more than 120 secs
Please login to merge, or discard this patch.
lib/core/contentparameters.php 1 patch
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -64,12 +64,13 @@
 block discarded – undo
64 64
      * @return int/boolean          returns false if value is not defined
65 65
      */
66 66
     public function BodyPreference($type) {
67
-        if (!isset($this->bodypref))
68
-            $this->bodypref = array();
67
+        if (!isset($this->bodypref)) {
68
+                    $this->bodypref = array();
69
+        }
69 70
 
70
-        if (isset($this->bodypref[$type]))
71
-            return $this->bodypref[$type];
72
-        else {
71
+        if (isset($this->bodypref[$type])) {
72
+                    return $this->bodypref[$type];
73
+        } else {
73 74
             $asb = new BodyPreference();
74 75
             $arr = (array)$this->bodypref;
75 76
             $arr[$type] = $asb;
Please login to merge, or discard this patch.
lib/core/redisconnection.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,8 +46,7 @@  discard block
 block discarded – undo
46 46
     function getKey($key) {
47 47
         try {
48 48
             return $this->redisObj->get($key);
49
-        }
50
-        catch(Exception $e) {
49
+        } catch(Exception $e) {
51 50
             ZLog::Write(LOGLEVEL_ERROR, sprintf("%s->getKey(): %s", get_class($this), $e->getMessage()));
52 51
         }
53 52
     }
@@ -55,20 +54,17 @@  discard block
 block discarded – undo
55 54
         try {
56 55
             if ($ttl > 0) {
57 56
                 return $this->redisObj->setEx($key, $ttl, $value);
58
-            }
59
-            else {
57
+            } else {
60 58
                 return $this->redisObj->set($key, $value);
61 59
             }
62
-        }
63
-        catch(Exception $e) {
60
+        } catch(Exception $e) {
64 61
             ZLog::Write(LOGLEVEL_ERROR, sprintf("%s->setKey(): %s", get_class($this), $e->getMessage()));
65 62
         }
66 63
     }
67 64
     function delKey($key) {
68 65
         try {
69 66
             return $this->redisObj->del($key);
70
-        }
71
-        catch(Exception $e) {
67
+        } catch(Exception $e) {
72 68
             ZLog::Write(LOGLEVEL_ERROR, sprintf("%s->delKey(): %s", get_class($this), $e->getMessage()));
73 69
         }
74 70
     }
Please login to merge, or discard this patch.
lib/core/stateobject.php 1 patch
Braces   +21 added lines, -20 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
      * @return array
21 21
      */
22 22
     public function GetID() {
23
-        if (!isset($this->SO_internalid))
24
-            $this->SO_internalid = sprintf('%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
23
+        if (!isset($this->SO_internalid)) {
24
+                    $this->SO_internalid = sprintf('%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
25
+        }
25 26
 
26 27
         return $this->SO_internalid;
27 28
     }
@@ -47,8 +48,9 @@  discard block
 block discarded – undo
47 48
         if (isset($this->data[$lname]) &&
48 49
                 ( (is_scalar($value) && !is_array($value) && $this->data[$lname] === $value) ||
49 50
                   (is_array($value) && is_array($this->data[$lname]) && $this->data[$lname] === $value)
50
-                ))
51
-            return false;
51
+                )) {
52
+                    return false;
53
+        }
52 54
 
53 55
         $this->data[$lname] = $value;
54 56
         $this->changed = true;
@@ -65,11 +67,13 @@  discard block
 block discarded – undo
65 67
     public function __get($name) {
66 68
         $lname = strtolower($name);
67 69
 
68
-        if (array_key_exists($lname, $this->data))
69
-            return $this->data[$lname];
70
+        if (array_key_exists($lname, $this->data)) {
71
+                    return $this->data[$lname];
72
+        }
70 73
 
71
-        if (isset($this->unsetdata) && is_array($this->unsetdata) && array_key_exists($lname, $this->unsetdata))
72
-            return $this->unsetdata[$lname];
74
+        if (isset($this->unsetdata) && is_array($this->unsetdata) && array_key_exists($lname, $this->unsetdata)) {
75
+                    return $this->unsetdata[$lname];
76
+        }
73 77
 
74 78
         return null;
75 79
     }
@@ -133,13 +137,14 @@  discard block
 block discarded – undo
133 137
         else if ($operator == "get" && count($arguments) == 1) {
134 138
             if (isset($this->$var)) {
135 139
                 return $this->$var;
140
+            } else {
141
+                            return $arguments[0];
136 142
             }
137
-            else
138
-                return $arguments[0];
139 143
         }
140 144
 
141
-        if ($operator == "has" && count($arguments) == 0)
142
-            return isset($this->$var);
145
+        if ($operator == "has" && count($arguments) == 0) {
146
+                    return isset($this->$var);
147
+        }
143 148
 
144 149
         if ($operator == "del" && count($arguments) == 0) {
145 150
             unset($this->$var);
@@ -201,8 +206,7 @@  discard block
 block discarded – undo
201 206
                 $this->data[$prop] = new $val->gsSyncStateClass;
202 207
                 $this->data[$prop]->jsonDeserialize($val);
203 208
                 $this->data[$prop]->postUnserialize();
204
-            }
205
-            else if (is_object($val)) {
209
+            } else if (is_object($val)) {
206 210
                 // json_decode converts arrays into objects, convert them back to arrays
207 211
                 $this->data[$prop] = [];
208 212
                 foreach ($val as $k => $v) {
@@ -211,19 +215,16 @@  discard block
 block discarded – undo
211 215
                         // TODO: case should be removed when removing ASDevice backwards compatibility
212 216
                         if (strcasecmp($v->gsSyncStateClass, "ASDevice") == 0) {
213 217
                             $this->data[$prop][$k] = new ASDevice(Request::GetDeviceID(), Request::GetDeviceType(), Request::GetGETUser(), Request::GetUserAgent());
214
-                        }
215
-                        else {
218
+                        } else {
216 219
                             $this->data[$prop][$k] = new $v->gsSyncStateClass;
217 220
                         }
218 221
                         $this->data[$prop][$k]->jsonDeserialize($v);
219 222
                         $this->data[$prop][$k]->postUnserialize();
220
-                    }
221
-                    else {
223
+                    } else {
222 224
                         $this->data[$prop][$k] = $v;
223 225
                     }
224 226
                 }
225
-            }
226
-            else {
227
+            } else {
227 228
                 $this->data[$prop] = $val;
228 229
             }
229 230
         }
Please login to merge, or discard this patch.
lib/core/statemanager.php 1 patch
Braces   +69 added lines, -54 removed lines patch added patch discarded remove patch
@@ -79,8 +79,9 @@  discard block
 block discarded – undo
79 79
         $synched = array();
80 80
         foreach ($this->device->GetAllFolderIds() as $folderid) {
81 81
             $uuid = $this->device->GetFolderUUID($folderid);
82
-            if ($uuid)
83
-                $synched[] = $folderid;
82
+            if ($uuid) {
83
+                            $synched[] = $folderid;
84
+            }
84 85
         }
85 86
         return $synched;
86 87
     }
@@ -107,12 +108,12 @@  discard block
 block discarded – undo
107 108
                 if ($data !== false) {
108 109
                     $this->synchedFolders[$folderid] = $data;
109 110
                 }
110
-            }
111
-            catch (StateNotFoundException $ex) { }
111
+            } catch (StateNotFoundException $ex) { }
112 112
         }
113 113
 
114
-        if (!isset($this->synchedFolders[$folderid]))
115
-            $this->synchedFolders[$folderid] = new SyncParameters();
114
+        if (!isset($this->synchedFolders[$folderid])) {
115
+                    $this->synchedFolders[$folderid] = new SyncParameters();
116
+        }
116 117
 
117 118
         return $this->synchedFolders[$folderid];
118 119
     }
@@ -148,8 +149,7 @@  discard block
 block discarded – undo
148 149
         if(!isset($synckey) || $synckey == "0" || $synckey == false) {
149 150
             $this->uuid = $this->getNewUuid();
150 151
             $this->newStateCounter = 1;
151
-        }
152
-        else {
152
+        } else {
153 153
             list($uuid, $counter) = self::ParseStateKey($synckey);
154 154
             $this->uuid = $uuid;
155 155
             $this->newStateCounter = $counter + 1;
@@ -189,8 +189,9 @@  discard block
 block discarded – undo
189 189
         list($this->uuid, $this->oldStateCounter) = self::ParseStateKey($synckey);
190 190
 
191 191
         // make sure the hierarchy cache is in place
192
-        if ($this->hierarchyOperation || $forceHierarchyLoading)
193
-            $this->loadHierarchyCache($forceHierarchyLoading);
192
+        if ($this->hierarchyOperation || $forceHierarchyLoading) {
193
+                    $this->loadHierarchyCache($forceHierarchyLoading);
194
+        }
194 195
 
195 196
         // the state machine will discard any sync states before this one, as they are no longer required
196 197
         return $this->statemachine->GetState($this->device->GetDeviceId(), IStateMachine::DEFTYPE, $this->uuid, $this->oldStateCounter, $this->deleteOldStates);
@@ -209,12 +210,14 @@  discard block
 block discarded – undo
209 210
      */
210 211
     public function SetSyncState($synckey, $syncstate, $folderid = false) {
211 212
         $internalkey = self::BuildStateKey($this->uuid, $this->newStateCounter);
212
-        if ($this->oldStateCounter != 0 && $synckey != $internalkey)
213
-            throw new StateInvalidException(sprintf("Unexpected synckey value oldcounter: '%s' synckey: '%s' internal key: '%s'", $this->oldStateCounter, $synckey, $internalkey));
213
+        if ($this->oldStateCounter != 0 && $synckey != $internalkey) {
214
+                    throw new StateInvalidException(sprintf("Unexpected synckey value oldcounter: '%s' synckey: '%s' internal key: '%s'", $this->oldStateCounter, $synckey, $internalkey));
215
+        }
214 216
 
215 217
         // make sure the hierarchy cache is also saved
216
-        if ($this->hierarchyOperation)
217
-            $this->saveHierarchyCache();
218
+        if ($this->hierarchyOperation) {
219
+                    $this->saveHierarchyCache();
220
+        }
218 221
 
219 222
         // announce this uuid to the device, while old uuid/states should be deleted
220 223
         self::LinkState($this->device, $this->uuid, $folderid);
@@ -229,13 +232,13 @@  discard block
 block discarded – undo
229 232
      * @return array/boolean    false if not available
230 233
      */
231 234
     public function GetSyncFailState() {
232
-        if (!$this->uuid)
233
-            return false;
235
+        if (!$this->uuid) {
236
+                    return false;
237
+        }
234 238
 
235 239
         try {
236 240
             return $this->statemachine->GetState($this->device->GetDeviceId(), IStateMachine::FAILSAVE, $this->uuid, $this->oldStateCounter, $this->deleteOldStates);
237
-        }
238
-        catch (StateNotFoundException $snfex) {
241
+        } catch (StateNotFoundException $snfex) {
239 242
             return false;
240 243
         }
241 244
     }
@@ -249,8 +252,9 @@  discard block
 block discarded – undo
249 252
      * @return boolean
250 253
      */
251 254
     public function SetSyncFailState($syncstate) {
252
-        if ($this->oldStateCounter == 0)
253
-            return false;
255
+        if ($this->oldStateCounter == 0) {
256
+                    return false;
257
+        }
254 258
 
255 259
         return $this->statemachine->SetState($syncstate, $this->device->GetDeviceId(), IStateMachine::FAILSAVE, $this->uuid, $this->oldStateCounter);
256 260
     }
@@ -266,12 +270,12 @@  discard block
 block discarded – undo
266 270
      */
267 271
     public function GetBackendStorage($type = self::BACKENDSTORAGE_PERMANENT) {
268 272
         if ($type == self::BACKENDSTORAGE_STATE) {
269
-            if (!$this->uuid)
270
-                throw new StateNotYetAvailableException();
273
+            if (!$this->uuid) {
274
+                            throw new StateNotYetAvailableException();
275
+            }
271 276
 
272 277
             return $this->statemachine->GetState($this->device->GetDeviceId(), IStateMachine::BACKENDSTORAGE, $this->uuid, $this->oldStateCounter, $this->deleteOldStates);
273
-        }
274
-        else {
278
+        } else {
275 279
             return $this->statemachine->GetState($this->device->GetDeviceId(), IStateMachine::BACKENDSTORAGE, false, $this->device->GetFirstSyncTime(), false);
276 280
         }
277 281
     }
@@ -288,13 +292,13 @@  discard block
 block discarded – undo
288 292
      */
289 293
     public function SetBackendStorage($data, $type = self::BACKENDSTORAGE_PERMANENT) {
290 294
         if ($type == self::BACKENDSTORAGE_STATE) {
291
-            if (!$this->uuid)
292
-                throw new StateNotYetAvailableException();
295
+            if (!$this->uuid) {
296
+                            throw new StateNotYetAvailableException();
297
+            }
293 298
 
294 299
             // TODO serialization should be done in the StateMachine
295 300
             return $this->statemachine->SetState($data, $this->device->GetDeviceId(), IStateMachine::BACKENDSTORAGE, $this->uuid, $this->newStateCounter);
296
-        }
297
-        else {
301
+        } else {
298 302
             return $this->statemachine->SetState($data, $this->device->GetDeviceId(), IStateMachine::BACKENDSTORAGE, false, $this->device->GetFirstSyncTime());
299 303
         }
300 304
     }
@@ -311,11 +315,13 @@  discard block
 block discarded – undo
311 315
      * @return boolean
312 316
      */
313 317
     public function InitializeFolderCache($folders) {
314
-        if (!is_array($folders))
315
-            return false;
318
+        if (!is_array($folders)) {
319
+                    return false;
320
+        }
316 321
 
317
-        if (!isset($this->device))
318
-            throw new FatalException("ASDevice not initialized");
322
+        if (!isset($this->device)) {
323
+                    throw new FatalException("ASDevice not initialized");
324
+        }
319 325
 
320 326
         // redeclare this operation as hierarchyOperation
321 327
         $this->hierarchyOperation = true;
@@ -377,10 +383,11 @@  discard block
 block discarded – undo
377 383
      * @return boolean
378 384
      */
379 385
     static public function UnLinkState(&$device, $folderid, $removeFromDevice = true, $retrieveUUIDFromDevice = true) {
380
-        if ($retrieveUUIDFromDevice === true)
381
-            $savedUuid = $device->GetFolderUUID($folderid);
382
-        else
383
-            $savedUuid = $retrieveUUIDFromDevice;
386
+        if ($retrieveUUIDFromDevice === true) {
387
+                    $savedUuid = $device->GetFolderUUID($folderid);
388
+        } else {
389
+                    $savedUuid = $retrieveUUIDFromDevice;
390
+        }
384 391
 
385 392
         if ($savedUuid) {
386 393
             ZLog::Write(LOGLEVEL_DEBUG, sprintf("StateManager::UnLinkState('%s'): saved state '%s' will be deleted.", $folderid, $savedUuid));
@@ -392,14 +399,16 @@  discard block
 block discarded – undo
392 399
             // remove all messages which could not be synched before
393 400
             $device->RemoveIgnoredMessage($folderid, false);
394 401
 
395
-            if ($folderid === false && $savedUuid !== false)
396
-                ZPush::GetStateMachine()->CleanStates($device->GetDeviceId(), IStateMachine::HIERARCHY, $savedUuid, self::FIXEDHIERARCHYCOUNTER *2);
402
+            if ($folderid === false && $savedUuid !== false) {
403
+                            ZPush::GetStateMachine()->CleanStates($device->GetDeviceId(), IStateMachine::HIERARCHY, $savedUuid, self::FIXEDHIERARCHYCOUNTER *2);
404
+            }
397 405
         }
398 406
         // delete this id from the uuid cache
399
-        if ($removeFromDevice)
400
-            return $device->SetFolderUUID(false, $folderid);
401
-        else
402
-            return true;
407
+        if ($removeFromDevice) {
408
+                    return $device->SetFolderUUID(false, $folderid);
409
+        } else {
410
+                    return true;
411
+        }
403 412
     }
404 413
 
405 414
     /**
@@ -413,8 +422,9 @@  discard block
 block discarded – undo
413 422
      */
414 423
     static public function ParseStateKey($synckey) {
415 424
         $matches = array();
416
-        if(!preg_match('/^\{([0-9A-Za-z-]+)\}([0-9]+)$/', $synckey, $matches))
417
-            throw new StateInvalidException(sprintf("SyncKey '%s' is invalid", $synckey));
425
+        if(!preg_match('/^\{([0-9A-Za-z-]+)\}([0-9]+)$/', $synckey, $matches)) {
426
+                    throw new StateInvalidException(sprintf("SyncKey '%s' is invalid", $synckey));
427
+        }
418 428
 
419 429
         return array($matches[1], (int)$matches[2]);
420 430
     }
@@ -430,8 +440,9 @@  discard block
 block discarded – undo
430 440
      * @throws StateInvalidException
431 441
      */
432 442
     static public function BuildStateKey($uuid, $counter) {
433
-        if(!preg_match('/^([0-9A-Za-z-]+)$/', $uuid, $matches))
434
-            throw new StateInvalidException(sprintf("UUID '%s' is invalid", $uuid));
443
+        if(!preg_match('/^([0-9A-Za-z-]+)$/', $uuid, $matches)) {
444
+                    throw new StateInvalidException(sprintf("UUID '%s' is invalid", $uuid));
445
+        }
435 446
 
436 447
         return "{" . $uuid . "}" . $counter;
437 448
     }
@@ -452,8 +463,9 @@  discard block
 block discarded – undo
452 463
      * @throws StateNotFoundException
453 464
      */
454 465
     private function loadHierarchyCache($forceLoading = false) {
455
-        if (!$this->hierarchyOperation && $forceLoading == false)
456
-            return false;
466
+        if (!$this->hierarchyOperation && $forceLoading == false) {
467
+                    return false;
468
+        }
457 469
 
458 470
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("StateManager->loadHierarchyCache(): '%s-%s-%s-%d'", $this->device->GetDeviceId(), $this->uuid, IStateMachine::HIERARCHY, $this->oldStateCounter));
459 471
 
@@ -479,17 +491,20 @@  discard block
 block discarded – undo
479 491
      * @throws StateInvalidException
480 492
      */
481 493
     private function saveHierarchyCache($forceSaving = false) {
482
-        if (!$this->hierarchyOperation && !$forceSaving)
483
-            return false;
494
+        if (!$this->hierarchyOperation && !$forceSaving) {
495
+                    return false;
496
+        }
484 497
 
485 498
         // link the hierarchy cache again, if the UUID does not match the UUID saved in the devicedata
486
-        if (($this->uuid != $this->device->GetFolderUUID() || $forceSaving) )
487
-            self::LinkState($this->device, $this->uuid);
499
+        if (($this->uuid != $this->device->GetFolderUUID() || $forceSaving) ) {
500
+                    self::LinkState($this->device, $this->uuid);
501
+        }
488 502
 
489 503
         // check all folders and deleted folders to update data of ASDevice and delete old states
490 504
         $hc = $this->device->getHierarchyCache();
491
-        foreach ($hc->GetDeletedFolders() as $delfolder)
492
-            self::UnLinkState($this->device, $delfolder->serverid);
505
+        foreach ($hc->GetDeletedFolders() as $delfolder) {
506
+                    self::UnLinkState($this->device, $delfolder->serverid);
507
+        }
493 508
 
494 509
         foreach ($hc->ExportFolders() as $folder) {
495 510
             $this->device->SetFolderType($folder->serverid, $folder->type);
Please login to merge, or discard this patch.
lib/core/asdevice.php 1 patch
Braces   +51 added lines, -45 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
         if (!$stripHierarchyCache && $this->hierarchyCache !== false && $this->hierarchyCache instanceof ChangesMemoryWrapper) {
84 84
             $this->hierarchyCache->StripData();
85
-        }
86
-        else {
85
+        } else {
87 86
             unset($this->hierarchyCache);
88 87
         }
89 88
 
@@ -122,8 +121,9 @@  discard block
 block discarded – undo
122 121
      * @return string
123 122
      */
124 123
     public function GetDeviceUserAgent() {
125
-        if (!isset($this->useragent) || !$this->useragent)
126
-            return "unknown";
124
+        if (!isset($this->useragent) || !$this->useragent) {
125
+                    return "unknown";
126
+        }
127 127
 
128 128
         return $this->useragent;
129 129
     }
@@ -148,8 +148,9 @@  discard block
 block discarded – undo
148 148
      * @return boolean
149 149
      */
150 150
     public function SetUserAgent($useragent) {
151
-        if ($useragent == $this->useragent || $useragent === false || $useragent === Request::UNKNOWN)
152
-            return true;
151
+        if ($useragent == $this->useragent || $useragent === false || $useragent === Request::UNKNOWN) {
152
+                    return true;
153
+        }
153 154
 
154 155
         // save the old user agent, if available
155 156
         if ($this->useragent != "") {
@@ -179,19 +180,22 @@  discard block
 block discarded – undo
179 180
         // we should have all previousily ignored messages in an id array
180 181
         if (count($this->ignoredMessages) != count($this->ignoredMessageIds)) {
181 182
             foreach($this->ignoredMessages as $oldMessage) {
182
-                if (!isset($this->ignoredMessageIds[$oldMessage->data->folderid]))
183
-                    $this->ignoredMessageIds[$oldMessage->data->folderid] = array();
183
+                if (!isset($this->ignoredMessageIds[$oldMessage->data->folderid])) {
184
+                                    $this->ignoredMessageIds[$oldMessage->data->folderid] = array();
185
+                }
184 186
                 $this->ignoredMessageIds[$oldMessage->data->folderid][] = $oldMessage->id;
185 187
             }
186 188
         }
187 189
 
188 190
         // try not to add the same message several times
189 191
         if (isset($ignoredMessage->folderid) && isset($ignoredMessage->id)) {
190
-            if (!isset($this->ignoredMessageIds[$ignoredMessage->folderid]))
191
-                $this->ignoredMessageIds[$ignoredMessage->folderid] = array();
192
+            if (!isset($this->ignoredMessageIds[$ignoredMessage->folderid])) {
193
+                            $this->ignoredMessageIds[$ignoredMessage->folderid] = array();
194
+            }
192 195
 
193
-            if (in_array($ignoredMessage->id, $this->ignoredMessageIds[$ignoredMessage->folderid]))
194
-                $this->RemoveIgnoredMessage($ignoredMessage->folderid, $ignoredMessage->id);
196
+            if (in_array($ignoredMessage->id, $this->ignoredMessageIds[$ignoredMessage->folderid])) {
197
+                            $this->RemoveIgnoredMessage($ignoredMessage->folderid, $ignoredMessage->id);
198
+            }
195 199
 
196 200
             $this->ignoredMessageIds[$ignoredMessage->folderid][] = $ignoredMessage->id;
197 201
             $msges = $this->ignoredMessages;
@@ -200,8 +204,7 @@  discard block
 block discarded – undo
200 204
             $this->changed = true;
201 205
 
202 206
             return true;
203
-        }
204
-        else {
207
+        } else {
205 208
             $msges = $this->ignoredMessages;
206 209
             $msges[] = $ignoredMessage;
207 210
             $this->ignoredMessages = $msges;
@@ -224,8 +227,9 @@  discard block
 block discarded – undo
224 227
         // we should have all previousily ignored messages in an id array
225 228
         if (count($this->ignoredMessages) != count($this->ignoredMessageIds)) {
226 229
             foreach($this->ignoredMessages as $oldMessage) {
227
-                if (!isset($this->ignoredMessageIds[$oldMessage->data->folderid]))
228
-                    $this->ignoredMessageIds[$oldMessage->data->folderid] = array();
230
+                if (!isset($this->ignoredMessageIds[$oldMessage->data->folderid])) {
231
+                                    $this->ignoredMessageIds[$oldMessage->data->folderid] = array();
232
+                }
229 233
                 $this->ignoredMessageIds[$oldMessage->data->folderid][] = $oldMessage->data->id;
230 234
             }
231 235
         }
@@ -243,14 +247,13 @@  discard block
 block discarded – undo
243 247
                             $foundMessage = true;
244 248
                             if (count($this->ignoredMessageIds[$folderid]) == 1) {
245 249
                                 unset($this->ignoredMessageIds[$folderid]);
246
-                            }
247
-                            else {
250
+                            } else {
248 251
                                 unset($this->ignoredMessageIds[$folderid][array_search($id, $this->ignoredMessageIds[$folderid])]);
249 252
                             }
250 253
                             continue;
254
+                        } else {
255
+                                                    $newMessages[] = $im;
251 256
                         }
252
-                        else
253
-                            $newMessages[] = $im;
254 257
                     }
255 258
                 }
256 259
                 $this->ignoredMessages = $newMessages;
@@ -274,8 +277,9 @@  discard block
 block discarded – undo
274 277
         // we should have all previousily ignored messages in an id array
275 278
         if (count($this->ignoredMessages) != count($this->ignoredMessageIds)) {
276 279
             foreach($this->ignoredMessages as $oldMessage) {
277
-                if (!isset($this->ignoredMessageIds[$oldMessage->data->folderid]))
278
-                    $this->ignoredMessageIds[$oldMessage->data->folderid] = array();
280
+                if (!isset($this->ignoredMessageIds[$oldMessage->data->folderid])) {
281
+                                    $this->ignoredMessageIds[$oldMessage->data->folderid] = array();
282
+                }
279 283
                 $this->ignoredMessageIds[$oldMessage->data->folderid][] = $oldMessage->data->id;
280 284
             }
281 285
         }
@@ -312,12 +316,13 @@  discard block
 block discarded – undo
312 316
         if ($hierarchydata !== false && $hierarchydata instanceof ChangesMemoryWrapper) {
313 317
             $this->hierarchyCache = $hierarchydata;
314 318
             $this->hierarchyCache->CopyOldState();
319
+        } else {
320
+                    $this->hierarchyCache = new ChangesMemoryWrapper();
315 321
         }
316
-        else
317
-            $this->hierarchyCache = new ChangesMemoryWrapper();
318 322
 
319
-        if (is_array($hierarchydata))
320
-            return $this->hierarchyCache->ImportFolders($hierarchydata);
323
+        if (is_array($hierarchydata)) {
324
+                    return $this->hierarchyCache->ImportFolders($hierarchydata);
325
+        }
321 326
         return true;
322 327
     }
323 328
 
@@ -328,8 +333,9 @@  discard block
 block discarded – undo
328 333
      * @return string
329 334
      */
330 335
     public function GetHierarchyCacheData() {
331
-        if (isset($this->hierarchyCache))
332
-            return $this->hierarchyCache;
336
+        if (isset($this->hierarchyCache)) {
337
+                    return $this->hierarchyCache;
338
+        }
333 339
 
334 340
         ZLog::Write(LOGLEVEL_WARN, "ASDevice->GetHierarchyCacheData() has no data! HierarchyCache probably never initialized.");
335 341
         return false;
@@ -342,8 +348,9 @@  discard block
 block discarded – undo
342 348
      * @return object   HierarchyCache
343 349
      */
344 350
     public function GetHierarchyCache() {
345
-        if (!isset($this->hierarchyCache))
346
-            $this->SetHierarchyCache();
351
+        if (!isset($this->hierarchyCache)) {
352
+                    $this->SetHierarchyCache();
353
+        }
347 354
 
348 355
         ZLog::Write(LOGLEVEL_DEBUG, "ASDevice->GetHierarchyCache(): ". $this->hierarchyCache->GetStat());
349 356
         return $this->hierarchyCache;
@@ -356,8 +363,9 @@  discard block
 block discarded – undo
356 363
      * @return array
357 364
      */
358 365
     public function GetAllFolderIds() {
359
-        if (isset($this->contentData) && is_array($this->contentData))
360
-            return array_keys($this->contentData);
366
+        if (isset($this->contentData) && is_array($this->contentData)) {
367
+                    return array_keys($this->contentData);
368
+        }
361 369
         return array();
362 370
     }
363 371
 
@@ -372,8 +380,7 @@  discard block
 block discarded – undo
372 380
     public function GetFolderUUID($folderid = false) {
373 381
         if ($folderid === false) {
374 382
             return (isset($this->hierarchyUuid) && $this->hierarchyUuid !== self::UNDEFINED) ? $this->hierarchyUuid : false;
375
-        }
376
-        else if (isset($this->contentData[$folderid]->{self::FOLDERUUID})) {
383
+        } else if (isset($this->contentData[$folderid]->{self::FOLDERUUID})) {
377 384
             return $this->contentData[$folderid]->{self::FOLDERUUID};
378 385
         }
379 386
         return false;
@@ -400,8 +407,7 @@  discard block
 block discarded – undo
400 407
                 $this->backend2folderidCache = false;
401 408
             }
402 409
             $this->changed = true;
403
-        }
404
-        else {
410
+        } else {
405 411
             $contentData = $this->contentData;
406 412
 
407 413
             if (!isset($contentData[$folderid])) {
@@ -415,8 +421,7 @@  discard block
 block discarded – undo
415 421
 
416 422
             if ($uuid) {
417 423
                 $contentData[$folderid]->{self::FOLDERUUID} = $uuid;
418
-            }
419
-            else {
424
+            } else {
420 425
                 $contentData[$folderid]->{self::FOLDERUUID} = false;
421 426
             }
422 427
 
@@ -610,9 +615,10 @@  discard block
 block discarded – undo
610 615
     public function GetSupportedFields($folderid) {
611 616
         if (isset($this->contentData) && isset($this->contentData[$folderid]) &&
612 617
             isset($this->contentData[$folderid]->{self::FOLDERUUID}) && $this->contentData[$folderid]->{self::FOLDERUUID} !== false &&
613
-            isset($this->contentData[$folderid]->{self::FOLDERSUPPORTEDFIELDS}) )
614
-
618
+            isset($this->contentData[$folderid]->{self::FOLDERSUPPORTEDFIELDS}) ) {
619
+        
615 620
             return $this->contentData[$folderid]->{self::FOLDERSUPPORTEDFIELDS};
621
+        }
616 622
 
617 623
         return false;
618 624
     }
@@ -671,8 +677,7 @@  discard block
 block discarded – undo
671 677
         }
672 678
         if ($status !== false) {
673 679
             $contentData[$folderid]->{self::FOLDERSYNCSTATUS} = $status;
674
-        }
675
-        else if (isset($contentData[$folderid]->{self::FOLDERSYNCSTATUS})) {
680
+        } else if (isset($contentData[$folderid]->{self::FOLDERSYNCSTATUS})) {
676 681
             unset($contentData[$folderid]->{self::FOLDERSYNCSTATUS});
677 682
         }
678 683
 
@@ -757,7 +762,9 @@  discard block
 block discarded – undo
757 762
         foreach ($this->additionalfolders as $k => $folder) {
758 763
             // This is fixed in fixstates, but we could keep this here a while longer.
759 764
             // TODO: remove line at a later point.
760
-            if (!isset($folder['parentid'])) $folder['parentid'] = "0";
765
+            if (!isset($folder['parentid'])) {
766
+                $folder['parentid'] = "0";
767
+            }
761 768
 
762 769
             if ($folder['name'] == $name && $folder['parentid'] == $parentid) {
763 770
                 ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because there is already an additional folder with the same name in the same folder: '%s'", $name));
@@ -919,8 +926,7 @@  discard block
 block discarded – undo
919 926
         foreach($this->additionalfolders as $keepFolder) {
920 927
             if ($keepFolder['store'] !== $store) {
921 928
                 $newAF[$keepFolder['folderid']] = $keepFolder;
922
-            }
923
-            else {
929
+            } else {
924 930
                 $noDupsCheck[$keepFolder['folderid']] = true;
925 931
             }
926 932
         }
Please login to merge, or discard this patch.
lib/core/provisioningmanager.php 1 patch
Braces   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -80,8 +80,7 @@  discard block
 block discarded – undo
80 80
             $this->policyHash = $d[self::KEY_POLICYHASH];
81 81
             $this->updatetime = $d[self::KEY_UPDATETIME];
82 82
             $this->loadtime = time();
83
-        }
84
-        else {
83
+        } else {
85 84
             $this->policyKey = ASDevice::UNDEFINED;
86 85
             $this->policyHash = ASDevice::UNDEFINED;
87 86
             $this->updatetime = 0;
@@ -115,16 +114,16 @@  discard block
 block discarded – undo
115 114
         // check if policiykey matches
116 115
         $p = ( ($policykey !== ASDevice::UNDEFINED && $policykey != $this->policyKey) || $this->policyKey == ASDevice::UNDEFINED );
117 116
 
118
-        if (!$noDebug || $p)
119
-            ZLog::Write(LOGLEVEL_DEBUG, sprintf("ProvisioningManager->ProvisioningRequired('%s') saved device key '%s': %s", $policykey, $this->policyKey, Utils::PrintAsString($p)));
117
+        if (!$noDebug || $p) {
118
+                    ZLog::Write(LOGLEVEL_DEBUG, sprintf("ProvisioningManager->ProvisioningRequired('%s') saved device key '%s': %s", $policykey, $this->policyKey, Utils::PrintAsString($p)));
119
+        }
120 120
 
121 121
         if ($checkPolicies) {
122 122
             $policyHash = $this->GetProvisioningObject()->GetPolicyHash();
123 123
             if ($this->policyHash !== ASDevice::UNDEFINED && $this->policyHash != $policyHash) {
124 124
                 $p = true;
125 125
                 ZLog::Write(LOGLEVEL_INFO, sprintf("ProvisioningManager->ProvisioningRequired(): saved policy hash '%s' changed to '%s'. Provisioning required.", $this->policyHash, $policyHash));
126
-            }
127
-            elseif (!$noDebug) {
126
+            } elseif (!$noDebug) {
128 127
                 ZLog::Write(LOGLEVEL_DEBUG, sprintf("ProvisioningManager->ProvisioningRequired() saved policy hash '%s' matches", $policyHash));
129 128
             }
130 129
         }
@@ -191,8 +190,7 @@  discard block
 block discarded – undo
191 190
                     if ($status >= SYNC_PROVISION_RWSTATUS_PENDING) {
192 191
                         ZLog::Write(LOGLEVEL_INFO, sprintf("ProvisioningManager->GetProvisioningWipeStatus(): REMOTE WIPE due for user '%s' on device '%s' - status: '%s'",  self::$user, self::$devid, $status));
193 192
                         $status = SYNC_PROVISION_RWSTATUS_PENDING;
194
-                    }
195
-                    else {
193
+                    } else {
196 194
                         ZLog::Write(LOGLEVEL_INFO, sprintf("ProvisioningManager->GetProvisioningWipeStatus(): no remote wipe pending - status: '%s'", $status));
197 195
                     }
198 196
             }
Please login to merge, or discard this patch.