lib/ext

Aleksander Machniak machniak at kolabsys.com
Mon Jan 14 14:02:52 CET 2013


 lib/ext/Syncroton/Command/Ping.php |   31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

New commits:
commit 9bf1a086fa224031d8c7403ea3aa8fdbba989e40
Author: Aleksander Machniak <alec at alec.pl>
Date:   Mon Jan 14 14:02:34 2013 +0100

    Small fix to last commit

diff --git a/lib/ext/Syncroton/Command/Ping.php b/lib/ext/Syncroton/Command/Ping.php
index 21131db..9a056e1 100644
--- a/lib/ext/Syncroton/Command/Ping.php
+++ b/lib/ext/Syncroton/Command/Ping.php
@@ -51,18 +51,22 @@ class Syncroton_Command_Ping extends Syncroton_Command_Wbxml
     {
         $intervalStart = time();
         $status = self::STATUS_NO_CHANGES_FOUND;
-        
+
         // the client does not send a wbxml document, if the Ping parameters did not change compared with the last request
-        if($this->_requestBody instanceof DOMDocument) {
+        if ($this->_requestBody instanceof DOMDocument) {
             $xml = simplexml_import_dom($this->_requestBody);
             $xml->registerXPathNamespace('Ping', 'Ping');
 
-            if(isset($xml->HeartBeatInterval)) {
-                $pingLifetime = (int)$xml->HeartBeatInterval;
+            if (isset($xml->HeartBeatInterval)) {
+                $lifeTime = (int)$xml->HeartBeatInterval;
+                if ($this->_device->pinglifetime != $lifeTime) {
+                    $this->_device->pinglifetime = $lifeTime;
+                    $need_update = true;
+                }
             }
 
-            $folders = array();
             if (isset($xml->Folders->Folder)) {
+                $folders = array();
                 foreach ($xml->Folders->Folder as $folderXml) {
                     try {
                         // does the folder exist?
@@ -76,20 +80,15 @@ class Syncroton_Command_Ping extends Syncroton_Command_Wbxml
                         break;
                     }
                 }
-            }
 
-            if ($pingLifetime && $this->_device->pinglifetime != $pinglifetime) {
-                $this->_device->pinglifetime = $pingLifetime;
-                $need_update = true;
-            }
-
-            $pingFolders = serialize(array_keys($folders));
-            if ($this->_device->pingfolder != $pingFolders) {
-                $this->_device->pingfolder = $pingFolders;
-                $need_update = true;
+                $pingFolders = serialize(array_keys($folders));
+                if ($this->_device->pingfolder != $pingFolders) {
+                    $this->_device->pingfolder = $pingFolders;
+                    $need_update = true;
+                }
             }
 
-            if ($need_update) {
+            if ($need_update && $status == self::STATUS_NO_CHANGES_FOUND) {
                 $this->_device = $this->_deviceBackend->update($this->_device);
             }
         }





More information about the commits mailing list