diff --git a/lib/Share/RoomShareProvider.php b/lib/Share/RoomShareProvider.php index 7604b85ea5f..3f57fb78d63 100644 --- a/lib/Share/RoomShareProvider.php +++ b/lib/Share/RoomShareProvider.php @@ -719,7 +719,7 @@ public function getSharesByIds(array $ids, ?string $recipientId = null): array { * @param bool $allRoomShares indicates that the passed in shares are all room shares for the user * @return list */ - private function resolveSharesForRecipient(array $shareMap, string $userId, ?string $path = null, bool $forChildren = false): array { + private function resolveSharesForRecipient(array $shareMap, string $userId, ?string $path = null, bool $forChildren = false, bool $allRoomShares = false): array { $qb = $this->dbConnection->getQueryBuilder(); $query = $qb->select('parent', 'permissions', 'file_target') @@ -732,15 +732,17 @@ private function resolveSharesForRecipient(array $shareMap, string $userId, ?str $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); - if ($path !== null) { - $path = str_replace('/' . $userId . '/files', '', $path); - $path = rtrim($path, '/'); + if ($path !== null || $allRoomShares) { + if ($path !== null) { + $path = str_replace('/' . $userId . '/files', '', $path); + $path = rtrim($path, '/'); - if ($forChildren) { - $qb->andWhere($qb->expr()->like('file_target', $qb->createNamedParameter($this->dbConnection->escapeLikeParameter($path) . '/_%'))); - } else { - $nonChildPath = $path === '' ? '/' : $path; - $qb->andWhere($qb->expr()->eq('file_target', $qb->createNamedParameter($nonChildPath))); + if ($forChildren) { + $qb->andWhere($qb->expr()->like('file_target', $qb->createNamedParameter($this->dbConnection->escapeLikeParameter($path) . '/_%'))); + } else { + $nonChildPath = $path === '' ? '/' : $path; + $qb->andWhere($qb->expr()->eq('file_target', $qb->createNamedParameter($nonChildPath))); + } } $stmt = $query->executeQuery(); @@ -938,7 +940,7 @@ private function _getSharedWith( $cursor->closeCursor(); } - $shares = $this->resolveSharesForRecipient($shares, $userId, $path, $forChildren); + $shares = $this->resolveSharesForRecipient($shares, $userId, $path, $forChildren, true); return $shares; }