aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-09-14 16:29:58 +0200
committerJoas Schilling <coding@schilljs.com>2016-09-14 16:29:58 +0200
commit08c6ca5a1a97d358a6aea9ce87ba8c8579be42c2 (patch)
tree60d374c68237d3eeeefbe5598557d5edd0f19034
parent62f31d67bdf7cceaf5eceecfa58f4d1f0ab4e168 (diff)
downloadnextcloud-server-08c6ca5a1a97d358a6aea9ce87ba8c8579be42c2.tar.gz
nextcloud-server-08c6ca5a1a97d358a6aea9ce87ba8c8579be42c2.zip
Chunk if you have too many contacts
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php26
1 files changed, 16 insertions, 10 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php
index b8491c08ff6..f7e0a017803 100644
--- a/apps/dav/lib/CardDAV/CardDavBackend.php
+++ b/apps/dav/lib/CardDAV/CardDavBackend.php
@@ -482,23 +482,29 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* @return array
*/
function getMultipleCards($addressBookId, array $uris) {
+ if (empty($uris)) {
+ return [];
+ }
+
+ $chunks = array_chunk($uris, 100);
+ $cards = [];
+
$query = $this->db->getQueryBuilder();
$query->select(['id', 'uri', 'lastmodified', 'etag', 'size', 'carddata'])
->from('cards')
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
- ->andWhere($query->expr()->in('uri', $query->createParameter('uri')))
- ->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY);
+ ->andWhere($query->expr()->in('uri', $query->createParameter('uri')));
- $cards = [];
+ foreach ($chunks as $uris) {
+ $query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY);
+ $result = $query->execute();
- $result = $query->execute();
- while($row = $result->fetch()) {
- $row['etag'] = '"' . $row['etag'] . '"';
- $row['carddata'] = $this->readBlob($row['carddata']);
- $cards[] = $row;
+ while($row = $result->fetch()) {
+ $row['etag'] = '"' . $row['etag'] . '"';
+ $row['carddata'] = $this->readBlob($row['carddata']);
+ $cards[] = $row;
+ }
}
- $result->closeCursor();
-
return $cards;
}