diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-04-27 14:46:28 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-05-12 15:03:25 +0200 |
commit | 81500bf83700a0faaa514e73df97d7fe67c98829 (patch) | |
tree | 0a3b80ac4babda97d36c7d8e60b1f81e7ab40867 /lib | |
parent | f7413b9afc2a29bef64f2cc207b318308cb6ebef (diff) | |
download | nextcloud-server-81500bf83700a0faaa514e73df97d7fe67c98829.tar.gz nextcloud-server-81500bf83700a0faaa514e73df97d7fe67c98829.zip |
Fix getting shares in a folder on Orache
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 9638706025b..520bd17d3cf 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -671,10 +671,10 @@ class DefaultShareProvider implements IShareProvider { } // todo? maybe get these from the oc_mounts table - $childMountNodes = array_filter($node->getDirectoryListing(), function (Node $node) { + $childMountNodes = array_filter($node->getDirectoryListing(), function (Node $node): bool { return $node->getInternalPath() === ''; }); - $childMountRootIds = array_map(function (Node $node) { + $childMountRootIds = array_map(function (Node $node): int { return $node->getId(); }, $childMountNodes); @@ -682,18 +682,29 @@ class DefaultShareProvider implements IShareProvider { $qb->andWhere( $qb->expr()->orX( $qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())), - $qb->expr()->in('f.fileid', $qb->createNamedParameter($childMountRootIds, IQueryBuilder::PARAM_INT_ARRAY)) + $qb->expr()->in('f.fileid', $qb->createParameter('chunk')) ) ); $qb->orderBy('id'); - $cursor = $qb->execute(); $shares = []; - while ($data = $cursor->fetch()) { - $shares[$data['fileid']][] = $this->createShare($data); + + $chunks = array_chunk($childMountRootIds, 1000); + + // Force the request to be run when there is 0 mount. + if (count($chunks) === 0) { + $chunks = [[]]; + } + + foreach ($chunks as $chunk) { + $qb->setParameter('chunk', $chunk, IQueryBuilder::PARAM_INT_ARRAY); + $cursor = $qb->executeQuery(); + while ($data = $cursor->fetch()) { + $shares[$data['fileid']][] = $this->createShare($data); + } + $cursor->closeCursor(); } - $cursor->closeCursor(); return $shares; } |