summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-01-10 16:06:44 +0100
committerJulius Härtl <jus@bitgrid.net>2020-04-23 19:08:16 +0200
commit6709833dc7248fe448b6b809584d9a2e9546af7b (patch)
tree10743c9d4fb37d7050e760c4f6a4e502353bed40 /apps/dav
parent3c2dd082640d2429c81639156291cb5978f60eec (diff)
downloadnextcloud-server-6709833dc7248fe448b6b809584d9a2e9546af7b.tar.gz
nextcloud-server-6709833dc7248fe448b6b809584d9a2e9546af7b.zip
Use paginated search for contacts
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CardDAV/AddressBookImpl.php2
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php6
2 files changed, 8 insertions, 0 deletions
diff --git a/apps/dav/lib/CardDAV/AddressBookImpl.php b/apps/dav/lib/CardDAV/AddressBookImpl.php
index 5e355611c11..3eea0f1d5c8 100644
--- a/apps/dav/lib/CardDAV/AddressBookImpl.php
+++ b/apps/dav/lib/CardDAV/AddressBookImpl.php
@@ -105,6 +105,8 @@ class AddressBookImpl implements IAddressBook {
* - 'types' boolean (since 15.0.0) If set to true, fields that come with a TYPE property will be an array
* example: ['id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => ['type => 'HOME', 'value' => 'g@h.i']]
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped
+ * - 'limit' - Set a numeric limit for the search results
+ * - 'offset' - Set the offset for the limited search results
* @return array an array of contacts which are arrays of key-value-pairs
* example result:
* [
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php
index f4de1b717fb..87e8e11cd16 100644
--- a/apps/dav/lib/CardDAV/CardDavBackend.php
+++ b/apps/dav/lib/CardDAV/CardDavBackend.php
@@ -965,6 +965,12 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
}
}
+ if (isset($options['limit'])) {
+ $query2->setMaxResults($options['limit']);
+ }
+ if (isset($options['offset'])) {
+ $query2->setFirstResult($options['offset']);
+ }
$query->select('c.carddata', 'c.uri')->from($this->dbCardsTable, 'c')
->where($query->expr()->in('c.id', $query->createFunction($query2->getSQL())));