From f4a8d152eb2fb1e5486f5bc3ecacd7b80700ce73 Mon Sep 17 00:00:00 2001 From: Louis Chmn Date: Fri, 30 Jan 2026 20:54:28 +0100 Subject: [PATCH] fix(files_sharing): Move path filtering to group share resolution Previously, this was preventing users without a specific USERGROUP entry to see GROUP shares. The path filtering is now done at resolution time. This is less efficient, but keeps the old behavior. Signed-off-by: Louis Chmn --- lib/private/Share20/DefaultShareProvider.php | 24 ++++++++------------ 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 46c2b94116217..b18bc2c5c3822 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -950,18 +950,6 @@ private function _getSharedWith( $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); } - if ($path !== null) { - $qb->leftJoin('s', 'share', 'sc', $qb->expr()->eq('sc.parent', 's.id')) - ->andWhere($qb->expr()->eq('sc.share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))) - ->where($qb->expr()->eq('sc.share_with', $qb->createNamedParameter($userId))); - - if ($forChildren) { - $qb->andWhere($qb->expr()->like('sc.file_target', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($path) . '_%'))); - } else { - $qb->andWhere($qb->expr()->eq('sc.file_target', $qb->createNamedParameter($path))); - } - } - $groups = array_filter($groups); $qb->andWhere($qb->expr()->eq('s.share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))) @@ -989,7 +977,7 @@ private function _getSharedWith( /* * Resolve all group shares to user specific shares */ - $shares = $this->resolveGroupShares($shares2, $userId); + $shares = $this->resolveGroupShares($shares2, $userId, $forChildren, $path); } else { throw new BackendError('Invalid backend'); } @@ -1105,7 +1093,7 @@ private function createShare($data) { * @param $userId * @return Share[] The updates shares if no update is found for a share return the original */ - private function resolveGroupShares($shareMap, $userId) { + private function resolveGroupShares($shareMap, $userId, bool $forChildren = false, ?string $path = null) { $qb = $this->dbConn->getQueryBuilder(); $query = $qb->select('*') ->from('share') @@ -1113,6 +1101,14 @@ private function resolveGroupShares($shareMap, $userId) { ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))) ->andWhere($qb->expr()->in('item_type', $qb->createNamedParameter(['file', 'folder'], IQueryBuilder::PARAM_STR_ARRAY))); + if ($path !== null) { + if ($forChildren) { + $qb->andWhere($qb->expr()->like('file_target', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($path) . '_%'))); + } else { + $qb->andWhere($qb->expr()->eq('file_target', $qb->createNamedParameter($path))); + } + } + // this is called with either all group shares or one group share. // for all shares it's easier to just only search by share_with, // for a single share it's efficient to filter by parent