mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
Merge pull request #36941 from nextcloud/bugfix/prevent-error-with-oracle-database
Split the comments ids by chunks
This commit is contained in:
commit
de64c96a67
2 changed files with 1223 additions and 8 deletions
|
|
@ -1031,6 +1031,7 @@ class Manager implements ICommentsManager {
|
|||
->select('message_id')
|
||||
->from('reactions')
|
||||
->where($qb->expr()->eq('parent_id', $qb->createNamedParameter($parentId)))
|
||||
->orderBy('message_id', 'DESC')
|
||||
->executeQuery();
|
||||
|
||||
$commentIds = [];
|
||||
|
|
@ -1106,22 +1107,29 @@ class Manager implements ICommentsManager {
|
|||
if (!$commentIds) {
|
||||
return [];
|
||||
}
|
||||
$query = $this->dbConn->getQueryBuilder();
|
||||
|
||||
$chunks = array_chunk($commentIds, 500);
|
||||
|
||||
$query = $this->dbConn->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from('comments')
|
||||
->where($query->expr()->in('id', $query->createNamedParameter($commentIds, IQueryBuilder::PARAM_STR_ARRAY)))
|
||||
->where($query->expr()->in('id', $query->createParameter('ids')))
|
||||
->orderBy('creation_timestamp', 'DESC')
|
||||
->addOrderBy('id', 'DESC');
|
||||
|
||||
$comments = [];
|
||||
$result = $query->executeQuery();
|
||||
while ($data = $result->fetch()) {
|
||||
$comment = $this->getCommentFromData($data);
|
||||
$this->cache($comment);
|
||||
$comments[] = $comment;
|
||||
foreach ($chunks as $ids) {
|
||||
$query->setParameter('ids', $ids, IQueryBuilder::PARAM_STR_ARRAY);
|
||||
|
||||
$result = $query->executeQuery();
|
||||
while ($data = $result->fetch()) {
|
||||
$comment = $this->getCommentFromData($data);
|
||||
$this->cache($comment);
|
||||
$comments[] = $comment;
|
||||
}
|
||||
$result->closeCursor();
|
||||
}
|
||||
$result->closeCursor();
|
||||
|
||||
return $comments;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue