diff --git a/lib/ACL/ACLManager.php b/lib/ACL/ACLManager.php index 602ae58b0..84baf570c 100644 --- a/lib/ACL/ACLManager.php +++ b/lib/ACL/ACLManager.php @@ -15,6 +15,7 @@ use OCP\Files\IRootFolder; use OCP\IUser; use Psr\Log\LoggerInterface; +use RuntimeException; class ACLManager { private CappedMemoryCache $ruleCache; @@ -97,6 +98,9 @@ private function getRelevantPaths(string $path): array { $groupFolderId = (int)$groupFolderId; /* Remove the date part */ $separatorPos = strrpos($rootTrashedItemName, '.d'); + if ($separatorPos === false) { + throw new RuntimeException('Invalid trash item name ' . $rootTrashedItemName); + } $rootTrashedItemDate = (int)substr($rootTrashedItemName, $separatorPos + 2); $rootTrashedItemName = substr($rootTrashedItemName, 0, $separatorPos); } @@ -105,6 +109,7 @@ private function getRelevantPaths(string $path): array { $path = dirname($path); if ($fromTrashbin && ($path === '__groupfolders/trash')) { /* We are in trash and hit the root folder, continue looking for ACLs on parent folders in original location */ + /** @psalm-suppress PossiblyUndefinedVariable Variables are defined above */ $trashItemRow = $this->trashManager->getTrashItemByFileName($groupFolderId, $rootTrashedItemName, $rootTrashedItemDate); $fromTrashbin = false; if ($trashItemRow) { diff --git a/lib/ACL/ACLStorageWrapper.php b/lib/ACL/ACLStorageWrapper.php index b80948a85..1d449a0f4 100644 --- a/lib/ACL/ACLStorageWrapper.php +++ b/lib/ACL/ACLStorageWrapper.php @@ -96,6 +96,10 @@ public function opendir($path) { } $handle = parent::opendir($path); + if ($handle === false) { + return false; + } + $items = []; while (($file = readdir($handle)) !== false) { if ($file !== '.' && $file !== '..') { diff --git a/lib/Mount/GroupMountPoint.php b/lib/Mount/GroupMountPoint.php index ee02ba8b8..9261711a6 100644 --- a/lib/Mount/GroupMountPoint.php +++ b/lib/Mount/GroupMountPoint.php @@ -7,6 +7,7 @@ namespace OCA\GroupFolders\Mount; use OC\Files\Mount\MountPoint; +use OC\Files\Storage\Storage; use OCP\Files\Mount\ISystemMountPoint; class GroupMountPoint extends MountPoint implements ISystemMountPoint { diff --git a/lib/Mount/MountProvider.php b/lib/Mount/MountProvider.php index edada0aa9..83030c6d0 100644 --- a/lib/Mount/MountProvider.php +++ b/lib/Mount/MountProvider.php @@ -215,6 +215,9 @@ public function getMount( return null; } $cacheEntry = $this->getRootFolder()->getStorage()->getCache()->get($folder->getId()); + if ($cacheEntry === false) { + return null; + } } $storage = $this->getRootFolder()->getStorage(); diff --git a/psalm.xml b/psalm.xml index 7d4074c62..76d8dd4da 100644 --- a/psalm.xml +++ b/psalm.xml @@ -4,7 +4,7 @@ - SPDX-License-Identifier: AGPL-3.0-or-later -->