]> source.dussan.org Git - nextcloud-server.git/commitdiff
LIMIT is no column but a SQL feature, allow limit on initial sync 10842/head
authorGeorg Ehrke <developer@georgehrke.com>
Fri, 24 Aug 2018 15:23:14 +0000 (17:23 +0200)
committerGeorg Ehrke <developer@georgehrke.com>
Thu, 18 Jul 2019 10:42:11 +0000 (12:42 +0200)
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
apps/dav/composer/composer/autoload_classmap.php
apps/dav/composer/composer/autoload_static.php
apps/dav/lib/CalDAV/CachedSubscription.php
apps/dav/lib/CalDAV/Calendar.php
apps/dav/lib/CardDAV/AddressBook.php
apps/dav/lib/CardDAV/CardDavBackend.php
apps/dav/lib/Exception/UnsupportedLimitOnInitialSyncException.php [new file with mode: 0644]

index 6452cd298d4b8bcfa2fe854d85093e2f9e84d606..b550e37a31c965e52fd81422ae3f932dae3eeeb3 100644 (file)
@@ -147,6 +147,7 @@ return array(
     'OCA\\DAV\\Direct\\DirectHome' => $baseDir . '/../lib/Direct/DirectHome.php',
     'OCA\\DAV\\Direct\\Server' => $baseDir . '/../lib/Direct/Server.php',
     'OCA\\DAV\\Direct\\ServerFactory' => $baseDir . '/../lib/Direct/ServerFactory.php',
+    'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => $baseDir . '/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
     'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => $baseDir . '/../lib/Files/BrowserErrorPagePlugin.php',
     'OCA\\DAV\\Files\\FileSearchBackend' => $baseDir . '/../lib/Files/FileSearchBackend.php',
     'OCA\\DAV\\Files\\FilesHome' => $baseDir . '/../lib/Files/FilesHome.php',
index 19c74d3be0752966b28c7732dd7b4075a05230cb..736b77aa11a21c07d3d4278d4b4d9c969e515c07 100644 (file)
@@ -162,6 +162,7 @@ class ComposerStaticInitDAV
         'OCA\\DAV\\Direct\\DirectHome' => __DIR__ . '/..' . '/../lib/Direct/DirectHome.php',
         'OCA\\DAV\\Direct\\Server' => __DIR__ . '/..' . '/../lib/Direct/Server.php',
         'OCA\\DAV\\Direct\\ServerFactory' => __DIR__ . '/..' . '/../lib/Direct/ServerFactory.php',
+        'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => __DIR__ . '/..' . '/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
         'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => __DIR__ . '/..' . '/../lib/Files/BrowserErrorPagePlugin.php',
         'OCA\\DAV\\Files\\FileSearchBackend' => __DIR__ . '/..' . '/../lib/Files/FileSearchBackend.php',
         'OCA\\DAV\\Files\\FilesHome' => __DIR__ . '/..' . '/../lib/Files/FilesHome.php',
index a95ee15bbe565cf072f822db8d455582390303d8..da8c5434cf23bb47a08d98a0addf44f52d38b394 100644 (file)
@@ -23,6 +23,7 @@ declare(strict_types=1);
  */
 namespace OCA\DAV\CalDAV;
 
+use OCA\DAV\Exception\UnsupportedLimitOnInitialSyncException;
 use Sabre\CalDAV\Backend\BackendInterface;
 use Sabre\DAV\Exception\MethodNotAllowed;
 use Sabre\DAV\Exception\NotFound;
@@ -195,4 +196,15 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar {
        public function calendarQuery(array $filters):array {
                return $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
        }
+
+       /**
+        * @inheritDoc
+        */
+       public function getChanges($syncToken, $syncLevel, $limit = null) {
+               if (!$syncToken && $limit) {
+                       throw new UnsupportedLimitOnInitialSyncException();
+               }
+
+               return parent::getChanges($syncToken, $syncLevel, $limit);
+       }
 }
index e80bffdb9d08f8c9c3f90a787096f4d7847a9c00..f26913d7ce19b2a343230a56512dfacfb0bf59f0 100644 (file)
@@ -27,6 +27,7 @@
 namespace OCA\DAV\CalDAV;
 
 use OCA\DAV\DAV\Sharing\IShareable;
+use OCA\DAV\Exception\UnsupportedLimitOnInitialSyncException;
 use OCP\IConfig;
 use OCP\IL10N;
 use Sabre\CalDAV\Backend\BackendInterface;
@@ -339,4 +340,14 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
                return isset($this->calendarInfo['{http://calendarserver.org/ns/}source']);
        }
 
+       /**
+        * @inheritDoc
+        */
+       public function getChanges($syncToken, $syncLevel, $limit = null) {
+               if (!$syncToken && $limit) {
+                       throw new UnsupportedLimitOnInitialSyncException();
+               }
+
+               return parent::getChanges($syncToken, $syncLevel, $limit);
+       }
 }
index 096f5c8b2a9a0c632ed8f29aa4eedc30404c28b6..3b02bdf5ba60399e387cfab7ac7cb5a420c642de 100644 (file)
@@ -23,6 +23,7 @@
 namespace OCA\DAV\CardDAV;
 
 use OCA\DAV\DAV\Sharing\IShareable;
+use OCA\DAV\Exception\UnsupportedLimitOnInitialSyncException;
 use OCP\IL10N;
 use Sabre\CardDAV\Backend\BackendInterface;
 use Sabre\CardDAV\Card;
@@ -219,4 +220,12 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
                }
                return true;
        }
+
+       public function getChanges($syncToken, $syncLevel, $limit = null) {
+               if (!$syncToken && $limit) {
+                       throw new UnsupportedLimitOnInitialSyncException();
+               }
+
+               return parent::getChanges($syncToken, $syncLevel, $limit);
+       }
 }
index f30a12bba4e73153aba3fa90c22427dda700230d..b16bcd993cf4354e914fd6f737e216d6c59a8360 100644 (file)
@@ -814,7 +814,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
 
                        $query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
                        if ($limit>0) {
-                               $query .= " `LIMIT` " . (int)$limit;
+                               $query .= " LIMIT " . (int)$limit;
                        }
 
                        // Fetching all changes
diff --git a/apps/dav/lib/Exception/UnsupportedLimitOnInitialSyncException.php b/apps/dav/lib/Exception/UnsupportedLimitOnInitialSyncException.php
new file mode 100644 (file)
index 0000000..b065a90
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * @copyright Copyright (c) 2019 Georg Ehrke
+ *
+ * @author Georg Ehrke <oc.list@georgehrke.com>
+ *
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+namespace OCA\DAV\Exception;
+
+use Sabre\DAV\Exception\InsufficientStorage;
+use Sabre\DAV\Server;
+
+/**
+ * Class UnsupportedLimitOnInitialSyncException
+ *
+ * @package OCA\DAV\Exception
+ */
+class UnsupportedLimitOnInitialSyncException extends InsufficientStorage {
+
+       /**
+        * @inheritDoc
+        */
+       public function serialize(Server $server, \DOMElement $errorNode) {
+               $errorNode->appendChild($errorNode->ownerDocument->createElementNS('DAV:', 'd:number-of-matches-within-limits'));
+       }
+}