diff --git a/lib/Db/TreeMapper.php b/lib/Db/TreeMapper.php index 8013a4dd0..1be1d849b 100644 --- a/lib/Db/TreeMapper.php +++ b/lib/Db/TreeMapper.php @@ -1151,14 +1151,18 @@ public function isFolderSharedWithUser(int $folderId, string $userId): bool { // noop } - $ancestors = $this->findParentsOf(TreeMapper::TYPE_FOLDER, $folderId);// FIXME: This will not find ancestors - foreach ($ancestors as $ancestorFolder) { - try { - $this->sharedFolderMapper->findByFolderAndUser($ancestorFolder->getId(), $userId); - return true; - } catch (DoesNotExistException) { - // noop + try { + while ($ancestorFolder = $this->findParentOf(TreeMapper::TYPE_FOLDER, $folderId)) { + try { + $this->sharedFolderMapper->findByFolderAndUser($ancestorFolder->getId(), $userId); + return true; + } catch (DoesNotExistException) { + // noop + } + $folderId = $ancestorFolder->getId(); } + } catch (DoesNotExistException $e) { + // noop } return false;