0011450: caldav sync with thunderbird stopped working
authorPaul Mehrer <p.mehrer@metaways.de>
Mon, 23 Nov 2015 14:19:47 +0000 (15:19 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 26 Nov 2015 08:47:05 +0000 (09:47 +0100)
WebDAV - SyncToken plugin - fixed requests with empty sync token

https://forge.tine20.org/view.php?id=11450

Change-Id: Icf286de4882798ab11ef86253dcf3ca7af158618
Reviewed-on: http://gerrit.tine20.com/customers/2421
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/WebDav/Plugin/SyncToken.php

index 17dd1f2..2429e23 100644 (file)
@@ -121,11 +121,15 @@ class Tinebase_WebDav_Plugin_SyncToken extends \Sabre\DAV\ServerPlugin
         if ($syncTokenList->length == 1) {
             $syncToken = $syncTokenList->item(0)->textContent; //?!? //nodeValue;
         }
-        // Sync-token must start with our prefix
-        if (substr($syncToken, 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX || strlen($syncToken) <= strlen(self::SYNCTOKEN_PREFIX)) {
-            throw new Sabre\DAV\Exception\BadRequest('Invalid or unknown sync token');
+        if (strlen($syncToken) > 0 ) {
+            // Sync-token must start with our prefix
+            if (substr($syncToken, 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX || strlen($syncToken) <= strlen(self::SYNCTOKEN_PREFIX)) {
+                throw new Sabre\DAV\Exception\BadRequest('Invalid or unknown sync token');
+            }
+            $syncToken = substr($syncToken, strlen(self::SYNCTOKEN_PREFIX));
+        } else {
+            $syncToken = 0;
         }
-        $syncToken = substr($syncToken, strlen(self::SYNCTOKEN_PREFIX));
 
         // get the list of properties the client requested
         $properties = array_keys(Sabre\DAV\XMLUtil::parseProperties($report->documentElement));