diff options
author | Stephan Orbaugh <62374139+sorbaugh@users.noreply.github.com> | 2024-03-25 15:32:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-25 15:32:08 +0100 |
commit | bc73ac63474573f035a9da37c7e68e541add80fb (patch) | |
tree | ae9209f8c9449ab28a3548c1a695296aca2c784a /apps | |
parent | b9c1383a26ec2d4e94572f5df5f368e369f09066 (diff) | |
parent | 7982645f6676aeb2bb7f2bdcea98dbd1580a4b9b (diff) | |
download | nextcloud-server-bc73ac63474573f035a9da37c7e68e541add80fb.tar.gz nextcloud-server-bc73ac63474573f035a9da37c7e68e541add80fb.zip |
Merge pull request #44415 from nextcloud/backport/44132/stable27
[stable27] fix: don't return null for SharedStorage::getWrapperStorage with share recursion
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/SharedStorage.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 42673313335..e84b3f5dda8 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,8 +142,21 @@ 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) { + // 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; } |