Chunk if you have too many events
This commit is contained in:
parent
e60d5d08e0
commit
33c39f7b27
|
@ -567,18 +567,24 @@ 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);
|
||||
->andWhere($query->expr()->in('uri', $query->createParameter('uri')));
|
||||
|
||||
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'],
|
||||
|
@ -590,7 +596,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
'component' => strtolower($row['componenttype']),
|
||||
'classification' => (int)$row['classification']
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue