Merge pull request #44323 from nextcloud/backport/44132/stable28

[stable28] fix: don't return null for SharedStorage::getWrapperStorage with share recursion
This commit is contained in:
Andy Scherzinger 2024-07-11 19:18:14 +02:00 committed by GitHub
commit 7b2c1836a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -97,6 +97,12 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
private string $sourcePath = '';
/**
* @psalm-suppress NonInvariantDocblockPropertyType
* @var ?\OC\Files\Storage\Storage $storage
*/
protected $storage;
private static int $initDepth = 0;
public function __construct($arguments) {
@ -134,8 +140,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;
}