Fix populating the array and closing the cursors

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-06-01 09:15:34 +02:00
parent fc8bd0be43
commit 128df0c2f8
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 3 additions and 3 deletions

View File

@ -655,16 +655,16 @@ class Manager implements ICommentsManager {
$query->andWhere($query->expr()->eq('c.verb', $query->createNamedParameter($verb))); $query->andWhere($query->expr()->eq('c.verb', $query->createNamedParameter($verb)));
} }
$unreadComments = array_fill_keys($objectIds, 0);
foreach (array_chunk($objectIds, 1000) as $chunk) { foreach (array_chunk($objectIds, 1000) as $chunk) {
$query->setParameter('ids', $chunk, IQueryBuilder::PARAM_INT_ARRAY); $query->setParameter('ids', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
$result = $query->execute();
$unreadComments += array_fill_keys($objectIds, 0); $result = $query->executeQuery();
while ($row = $result->fetch()) { while ($row = $result->fetch()) {
$unreadComments[$row['object_id']] = (int) $row['num_comments']; $unreadComments[$row['object_id']] = (int) $row['num_comments'];
} }
$result->closeCursor();
} }
$result->closeCursor();
return $unreadComments; return $unreadComments;
} }