diff options
author | Joas Schilling <coding@schilljs.com> | 2016-09-14 16:29:33 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2016-09-14 16:29:33 +0200 |
commit | 62f31d67bdf7cceaf5eceecfa58f4d1f0ab4e168 (patch) | |
tree | 8c1b3eda3cba7304b0045d4093fff292b89d0139 /apps | |
parent | 6cbde6329fc08cdc4db34723f0435a92303d042d (diff) | |
download | nextcloud-server-62f31d67bdf7cceaf5eceecfa58f4d1f0ab4e168.tar.gz nextcloud-server-62f31d67bdf7cceaf5eceecfa58f4d1f0ab4e168.zip |
Chunk if you have too many events
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 84ec8433a83..886dcd4f6d8 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -616,19 +616,25 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @return array */ function getMultipleCalendarObjects($calendarId, array $uris) { + if (empty($uris)) { + return []; + } + + $chunks = array_chunk($uris, 100); + $result = []; + $query = $this->db->getQueryBuilder(); $query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification']) - ->from('calendarobjects') - ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))) - ->andWhere($query->expr()->in('uri', $query->createParameter('uri'))) - ->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY); - - $stmt = $query->execute(); + ->from('calendarobjects') + ->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))) + ->andWhere($query->expr()->in('uri', $query->createParameter('uri'))); - $result = []; - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + foreach ($chunks as $uris) { + $query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY); + $stmt = $query->execute(); - $result[] = [ + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + $result[] = [ 'id' => $row['id'], 'uri' => $row['uri'], 'lastmodified' => $row['lastmodified'], @@ -638,8 +644,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription 'calendardata' => $this->readBlob($row['calendardata']), 'component' => strtolower($row['componenttype']), 'classification' => (int)$row['classification'] - ]; - + ]; + } } return $result; } |