diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-03-03 10:35:50 +0100 |
---|---|---|
committer | Côme Chilliet (Rebase PR Action) <come-nc@users.noreply.github.com> | 2023-03-13 17:36:10 +0000 |
commit | 9b1d7794a826cd87d0dce77c9ba7691a71137e48 (patch) | |
tree | 41aa59fe2f36518314256a37ec6874e72052a774 /lib | |
parent | 4b79e75072f59d2ada4a95413e730a14fe461e9c (diff) | |
download | nextcloud-server-9b1d7794a826cd87d0dce77c9ba7691a71137e48.tar.gz nextcloud-server-9b1d7794a826cd87d0dce77c9ba7691a71137e48.zip |
Add chunking in SystemTagObjectMapper::getTagIdsForObjects
This avoids crashing on Oracle with more than 1000 objects
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/SystemTag/SystemTagObjectMapper.php | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/private/SystemTag/SystemTagObjectMapper.php b/lib/private/SystemTag/SystemTagObjectMapper.php index 5a09a1754f2..b61a81a1fa7 100644 --- a/lib/private/SystemTag/SystemTagObjectMapper.php +++ b/lib/private/SystemTag/SystemTagObjectMapper.php @@ -77,23 +77,25 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { ->from(self::RELATION_TABLE) ->where($query->expr()->in('objectid', $query->createParameter('objectids'))) ->andWhere($query->expr()->eq('objecttype', $query->createParameter('objecttype'))) - ->setParameter('objectids', $objIds, IQueryBuilder::PARAM_STR_ARRAY) ->setParameter('objecttype', $objectType) ->addOrderBy('objectid', 'ASC') ->addOrderBy('systemtagid', 'ASC'); - + $chunks = array_chunk($objIds, 900, false); $mapping = []; foreach ($objIds as $objId) { $mapping[$objId] = []; } + foreach ($chunks as $chunk) { + $query->setParameter('objectids', $chunk, IQueryBuilder::PARAM_STR_ARRAY); + $result = $query->executeQuery(); + while ($row = $result->fetch()) { + $objectId = $row['objectid']; + $mapping[$objectId][] = $row['systemtagid']; + } - $result = $query->execute(); - while ($row = $result->fetch()) { - $objectId = $row['objectid']; - $mapping[$objectId][] = $row['systemtagid']; + $result->closeCursor(); } - $result->closeCursor(); return $mapping; } |