Chunk if you have too many events
This commit is contained in:
parent
e60d5d08e0
commit
33c39f7b27
|
@ -567,19 +567,25 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getMultipleCalendarObjects($calendarId, array $uris) {
|
function getMultipleCalendarObjects($calendarId, array $uris) {
|
||||||
|
if (empty($uris)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$chunks = array_chunk($uris, 100);
|
||||||
|
$result = [];
|
||||||
|
|
||||||
$query = $this->db->getQueryBuilder();
|
$query = $this->db->getQueryBuilder();
|
||||||
$query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification'])
|
$query->select(['id', 'uri', 'lastmodified', 'etag', 'calendarid', 'size', 'calendardata', 'componenttype', 'classification'])
|
||||||
->from('calendarobjects')
|
->from('calendarobjects')
|
||||||
->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
|
->where($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId)))
|
||||||
->andWhere($query->expr()->in('uri', $query->createParameter('uri')))
|
->andWhere($query->expr()->in('uri', $query->createParameter('uri')));
|
||||||
->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY);
|
|
||||||
|
|
||||||
$stmt = $query->execute();
|
foreach ($chunks as $uris) {
|
||||||
|
$query->setParameter('uri', $uris, IQueryBuilder::PARAM_STR_ARRAY);
|
||||||
|
$stmt = $query->execute();
|
||||||
|
|
||||||
$result = [];
|
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
$result[] = [
|
||||||
|
|
||||||
$result[] = [
|
|
||||||
'id' => $row['id'],
|
'id' => $row['id'],
|
||||||
'uri' => $row['uri'],
|
'uri' => $row['uri'],
|
||||||
'lastmodified' => $row['lastmodified'],
|
'lastmodified' => $row['lastmodified'],
|
||||||
|
@ -589,8 +595,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
'calendardata' => $this->readBlob($row['calendardata']),
|
'calendardata' => $this->readBlob($row['calendardata']),
|
||||||
'component' => strtolower($row['componenttype']),
|
'component' => strtolower($row['componenttype']),
|
||||||
'classification' => (int)$row['classification']
|
'classification' => (int)$row['classification']
|
||||||
];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue