Chunk if you have too many contacts
This commit is contained in:
parent
33c39f7b27
commit
5b8c7768b1
|
@ -439,23 +439,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