Skip to content

Commit

Permalink
Fix populating the array and closing the cursors
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen authored and szaimen committed Aug 31, 2021
1 parent bd62274 commit 1310025
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/private/Comments/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,16 +654,16 @@ public function getNumberOfUnreadCommentsForObjects(string $objectType, array $o
$query->andWhere($query->expr()->eq('c.verb', $query->createNamedParameter($verb)));
}

$unreadComments = array_fill_keys($objectIds, 0);
foreach (array_chunk($objectIds, 1000) as $chunk) {
$query->setParameter('ids', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
$result = $query->execute();

$unreadComments += array_fill_keys($objectIds, 0);
$result = $query->executeQuery();
while ($row = $result->fetch()) {
$unreadComments[$row['object_id']] = (int) $row['num_comments'];
}
$result->closeCursor();
}
$result->closeCursor();

return $unreadComments;
}
Expand Down

0 comments on commit 1310025

Please sign in to comment.