Chunk if you have too many contacts
This commit is contained in:
parent
62f31d67bd
commit
08c6ca5a1a
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue