From 9f0589451066c9ffdf92a2cd7554c0a0a630fafd Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Jan 2024 16:56:56 +0100 Subject: [PATCH] also filter by storage when getting shares in folder Signed-off-by: Robin Appelman --- .../lib/FederatedShareProvider.php | 3 ++- apps/sharebymail/lib/ShareByMailProvider.php | 1 + lib/private/Share20/DefaultShareProvider.php | 11 +++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 69813289cae38..ea0798445fa1e 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -605,8 +605,9 @@ public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = t $qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')); + $qb->andWhere($qb->expr()->eq('f.storage', $qb->createNamedParameter($node->getMountPoint()->getNumericStorageId(), IQueryBuilder::PARAM_INT))); if ($shallow) { - $qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId()))); + $qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId(), IQueryBuilder::PARAM_INT))); } else { $qb->andWhere($qb->expr()->like('f.path', $qb->createNamedParameter($this->dbConnection->escapeLikeParameter($node->getInternalPath()) . '/%'))); } diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 1c7b716e1e4aa..5a840b895ff02 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -1069,6 +1069,7 @@ public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = t $qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')); + $qb->andWhere($qb->expr()->eq('f.storage', $qb->createNamedParameter($node->getMountPoint()->getNumericStorageId(), IQueryBuilder::PARAM_INT))); if ($shallow) { $qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId()))); } else { diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index b4ec16936f354..50196402b4262 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -692,17 +692,24 @@ public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = t }, $childMountNodes); $qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')); + $storageFilter = $qb->expr()->eq('f.storage', $qb->createNamedParameter($node->getMountPoint()->getNumericStorageId(), IQueryBuilder::PARAM_INT)); if ($shallow) { $qb->andWhere( $qb->expr()->orX( - $qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())), + $qb->expr()->andX( + $storageFilter, + $qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())), + ), $qb->expr()->in('f.fileid', $qb->createParameter('chunk')) ) ); } else { $qb->andWhere( $qb->expr()->orX( - $qb->expr()->like('f.path', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($node->getInternalPath()) . '/%')), + $qb->expr()->andX( + $storageFilter, + $qb->expr()->like('f.path', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($node->getInternalPath()) . '/%')), + ), $qb->expr()->in('f.fileid', $qb->createParameter('chunk')) ) );