Browse Source
Merge pull request #27316 from nextcloud/bugfix/noid/getNumberOfUnreadCommentsForObjects
Fix populating the array and closing the cursors
pull/27340/head
Lukas Reschke
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
3 additions and
3 deletions
-
lib/private/Comments/Manager.php
|
|
|
@ -655,16 +655,16 @@ class Manager implements ICommentsManager { |
|
|
|
$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; |
|
|
|
} |
|
|
|
|