From 459c17492bf723297b2fd8014274ca45d9751e4d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 11 Mar 2024 17:07:49 +0100 Subject: fix: don't return null for SharedStorage::getWrapperStorage with share recursion Signed-off-by: Robin Appelman --- apps/files_sharing/lib/SharedStorage.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'apps') diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index ad43e847d37..be5656d64b5 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -138,6 +138,16 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto private function init() { if ($this->initialized) { + if (!$this->storage) { + // marked as initialized but no storage set + // this is probably because some code path has caused recursion during the share setup + // we setup a "failed storage" so `getWrapperStorage` doesn't return null. + // If the share setup completes after this the "failed storage" will be overwritten by the correct one + $this->logger->warning('Possible share setup recursion detected'); + $this->storage = new FailedStorage(['exception' => new \Exception('Possible share setup recursion detected')]); + $this->cache = new FailedCache(); + $this->rootPath = ''; + } return; } -- cgit v1.2.3 From 7982645f6676aeb2bb7f2bdcea98dbd1580a4b9b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 11 Mar 2024 17:21:29 +0100 Subject: chore: improve typing for SharedStorage::$storage Signed-off-by: Robin Appelman --- apps/files_sharing/lib/SharedStorage.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'apps') diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index be5656d64b5..de3b30b1b14 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -101,6 +101,12 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto private static int $initDepth = 0; + /** + * @psalm-suppress NonInvariantDocblockPropertyType + * @var ?\OC\Files\Storage\Storage $storage + */ + protected $storage; + public function __construct($arguments) { $this->ownerView = $arguments['ownerView']; $this->logger = \OC::$server->getLogger(); @@ -136,6 +142,9 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto return $this->sourceRootInfo; } + /** + * @psalm-assert \OC\Files\Storage\Storage $this->storage + */ private function init() { if ($this->initialized) { if (!$this->storage) { -- cgit v1.2.3