[Pkg-owncloud-commits] [php-sabredav] 22/31: Using a different property to internally pass the sync-token around.

David Prévot taffit at moszumanska.debian.org
Wed Aug 27 22:33:07 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit bd33d87a73c366fb3c639abccc0dd6896863d7a3
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Wed Aug 27 15:45:17 2014 +0200

    Using a different property to internally pass the sync-token around.
    
    Issue #496.
---
 lib/CalDAV/Backend/PDO.php                      |  6 +++---
 lib/CalDAV/Backend/SyncSupport.php              |  8 ++++----
 lib/CalDAV/Calendar.php                         |  6 ++++++
 lib/CalDAV/ICSExportPlugin.php                  |  2 +-
 lib/CardDAV/AddressBook.php                     |  6 ++++++
 lib/CardDAV/Backend/PDO.php                     |  6 +++---
 lib/CardDAV/Backend/SyncSupport.php             |  8 ++++----
 lib/DAV/Server.php                              |  9 +++++++++
 lib/DAV/Sync/Plugin.php                         |  2 +-
 tests/Sabre/CardDAV/Backend/AbstractPDOTest.php | 12 ++++++------
 10 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/lib/CalDAV/Backend/PDO.php b/lib/CalDAV/Backend/PDO.php
index 8cb3b4d..21d77f4 100644
--- a/lib/CalDAV/Backend/PDO.php
+++ b/lib/CalDAV/Backend/PDO.php
@@ -164,7 +164,7 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport {
                 'uri' => $row['uri'],
                 'principaluri' => $row['principaluri'],
                 '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
-                '{DAV:}sync-token' => $row['synctoken']?$row['synctoken']:'0',
+                '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
                 '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Property\SupportedCalendarComponentSet($components),
                 '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new CalDAV\Property\ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
             ];
@@ -757,8 +757,8 @@ class PDO extends AbstractBackend implements SyncSupport, SubscriptionSupport {
      * ];
      *
      * The returned syncToken property should reflect the *current* syncToken
-     * of the calendar, as reported in the {DAV:}sync-token property This is
-     * needed here too, to ensure the operation is atomic.
+     * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
+     * property this is needed here too, to ensure the operation is atomic.
      *
      * If the $syncToken argument is specified as null, this is an initial
      * sync, and all members should be reported.
diff --git a/lib/CalDAV/Backend/SyncSupport.php b/lib/CalDAV/Backend/SyncSupport.php
index 2e9ff90..d5ec4d6 100644
--- a/lib/CalDAV/Backend/SyncSupport.php
+++ b/lib/CalDAV/Backend/SyncSupport.php
@@ -11,8 +11,8 @@ namespace Sabre\CalDAV\Backend;
  * Implementing this can result in a significant reduction of bandwidth and CPU
  * time.
  *
- * For this to work, you _must_ return a {DAV:}sync-token property from
- * getCalendarsFromUser.
+ * For this to work, you _must_ return a {http://sabredav.org/ns}sync-token
+ * property from getCalendarsFromUser.
  *
  * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
  * @author Evert Pot (http://evertpot.com/)
@@ -41,8 +41,8 @@ interface SyncSupport extends BackendInterface {
      * );
      *
      * The returned syncToken property should reflect the *current* syncToken
-     * of the calendar, as reported in the {DAV:}sync-token property This is
-     * needed here too, to ensure the operation is atomic.
+     * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
+     * property This is * needed here too, to ensure the operation is atomic.
      *
      * If the $syncToken argument is specified as null, this is an initial
      * sync, and all members should be reported.
diff --git a/lib/CalDAV/Calendar.php b/lib/CalDAV/Calendar.php
index de008f2..9014290 100644
--- a/lib/CalDAV/Calendar.php
+++ b/lib/CalDAV/Calendar.php
@@ -446,6 +446,12 @@ class Calendar implements ICalendar, DAV\IProperties, DAVACL\IACL, DAV\Sync\ISyn
         ) {
             return $this->calendarInfo['{DAV:}sync-token'];
         }
+        if (
+            $this->caldavBackend instanceof Backend\SyncSupport &&
+            isset($this->calendarInfo['{http://sabredav.org/ns}sync-token'])
+        ) {
+            return $this->calendarInfo['{http://sabredav.org/ns}sync-token'];
+        }
 
     }
 
diff --git a/lib/CalDAV/ICSExportPlugin.php b/lib/CalDAV/ICSExportPlugin.php
index f2bdf5b..f16b758 100644
--- a/lib/CalDAV/ICSExportPlugin.php
+++ b/lib/CalDAV/ICSExportPlugin.php
@@ -83,7 +83,7 @@ class ICSExportPlugin extends DAV\ServerPlugin {
         $node = $this->server->getProperties($path, [
             '{DAV:}resourcetype',
             '{DAV:}displayname',
-            '{DAV:}sync-token',
+            '{http://sabredav.org/ns}sync-token',
             '{http://apple.com/ns/ical/}calendar-color',
         ]);
 
diff --git a/lib/CardDAV/AddressBook.php b/lib/CardDAV/AddressBook.php
index 05e8b41..8f6457b 100644
--- a/lib/CardDAV/AddressBook.php
+++ b/lib/CardDAV/AddressBook.php
@@ -351,6 +351,12 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie
         ) {
             return $this->addressBookInfo['{DAV:}sync-token'];
         }
+        if (
+            $this->carddavBackend instanceof Backend\SyncSupport &&
+            isset($this->addressBookInfo['{http://sabredav.org/ns}sync-token'])
+        ) {
+            return $this->addressBookInfo['{http://sabredav.org/ns}sync-token'];
+        }
 
     }
 
diff --git a/lib/CardDAV/Backend/PDO.php b/lib/CardDAV/Backend/PDO.php
index 3a03077..d8e39b9 100644
--- a/lib/CardDAV/Backend/PDO.php
+++ b/lib/CardDAV/Backend/PDO.php
@@ -80,7 +80,7 @@ class PDO extends AbstractBackend implements SyncSupport {
                 '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' =>
                     new CardDAV\Property\SupportedAddressData(),
-                '{DAV:}sync-token' => $row['synctoken']?$row['synctoken']:'0',
+                '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
             );
 
         }
@@ -433,8 +433,8 @@ class PDO extends AbstractBackend implements SyncSupport {
      * ];
      *
      * The returned syncToken property should reflect the *current* syncToken
-     * of the addressbook, as reported in the {DAV:}sync-token property This is
-     * needed here too, to ensure the operation is atomic.
+     * of the addressbook, as reported in the {http://sabredav.org/ns}sync-token
+     * property. This is needed here too, to ensure the operation is atomic.
      *
      * If the $syncToken argument is specified as null, this is an initial
      * sync, and all members should be reported.
diff --git a/lib/CardDAV/Backend/SyncSupport.php b/lib/CardDAV/Backend/SyncSupport.php
index 85deecd..26769cd 100644
--- a/lib/CardDAV/Backend/SyncSupport.php
+++ b/lib/CardDAV/Backend/SyncSupport.php
@@ -11,8 +11,8 @@ namespace Sabre\CardDAV\Backend;
  * Implementing this can result in a significant reduction of bandwidth and CPU
  * time.
  *
- * For this to work, you _must_ return a {DAV:}sync-token property from
- * getAddressBooksForUser.
+ * For this to work, you _must_ return a {http://sabredav.org/ns}sync-token
+ * property from getAddressBooksForUser.
  *
  * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
  * @author Evert Pot (http://evertpot.com/)
@@ -41,8 +41,8 @@ interface SyncSupport extends BackendInterface {
      * ];
      *
      * The returned syncToken property should reflect the *current* syncToken
-     * of the calendar, as reported in the {DAV:}sync-token property This is
-     * needed here too, to ensure the operation is atomic.
+     * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
+     * property. This is needed here too, to ensure the operation is atomic.
      *
      * If the $syncToken argument is specified as null, this is an initial
      * sync, and all members should be reported.
diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php
index 465b36f..97c8871 100644
--- a/lib/DAV/Server.php
+++ b/lib/DAV/Server.php
@@ -129,6 +129,15 @@ class Server extends EventEmitter {
         '{DAV:}supported-method-set',
         '{DAV:}supported-report-set',
 
+        // RFC6578
+        '{DAV:}sync-token',
+
+        // calendarserver.org extensions
+        '{http://calendarserver.org/ns/}ctag',
+
+        // sabredav extensions
+        '{http://sabredav.org/ns}sync-token',
+
     ];
 
     /**
diff --git a/lib/DAV/Sync/Plugin.php b/lib/DAV/Sync/Plugin.php
index 1aab30e..c4c13df 100644
--- a/lib/DAV/Sync/Plugin.php
+++ b/lib/DAV/Sync/Plugin.php
@@ -280,7 +280,7 @@ class Plugin extends DAV\ServerPlugin {
 
     /**
      * This method is triggered whenever properties are requested for a node.
-     * We intercept this to see if we can must return a {DAV:}sync-token.
+     * We intercept this to see if we must return a {DAV:}sync-token.
      *
      * @param DAV\PropFind $propFind
      * @param DAV\INode $node
diff --git a/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php b/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
index ffa086e..3a786f8 100644
--- a/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
+++ b/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
@@ -40,7 +40,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
                 '{http://calendarserver.org/ns/}getctag' => 1,
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
-                '{DAV:}sync-token' => 1
+                '{http://sabredav.org/ns}sync-token' => "1"
             )
         );
 
@@ -72,7 +72,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
                 '{http://calendarserver.org/ns/}getctag' => 1,
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
-                '{DAV:}sync-token' => 1
+                '{http://sabredav.org/ns}sync-token' => 1
             )
         );
 
@@ -100,7 +100,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
                 '{http://calendarserver.org/ns/}getctag' => 1,
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
-                '{DAV:}sync-token' => 1
+                '{http://sabredav.org/ns}sync-token' => 1
             )
         );
 
@@ -132,7 +132,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated',
                 '{http://calendarserver.org/ns/}getctag' => 2,
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
-                '{DAV:}sync-token' => 2
+                '{http://sabredav.org/ns}sync-token' => 2
             )
         );
 
@@ -176,7 +176,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
                 '{http://calendarserver.org/ns/}getctag' => 1,
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
-                '{DAV:}sync-token' => 1,
+                '{http://sabredav.org/ns}sync-token' => 1,
             ),
             array(
                 'id' => 2,
@@ -186,7 +186,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 2',
                 '{http://calendarserver.org/ns/}getctag' => 1,
                 '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
-                '{DAV:}sync-token' => 1,
+                '{http://sabredav.org/ns}sync-token' => 1,
             )
         );
         $result = $this->backend->getAddressBooksForUser('principals/user1');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list