Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't return null for SharedStorage::getWrapperStorage with share recursion #44132

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,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;
Fixed Show fixed Hide fixed

public function __construct($arguments) {
$this->ownerView = $arguments['ownerView'];
$this->logger = \OC::$server->get(LoggerInterface::class);
Expand Down Expand Up @@ -135,8 +141,21 @@ private function getSourceRootInfo() {
return $this->sourceRootInfo;
}

/**
* @psalm-assert \OC\Files\Storage\Storage $this->storage
*/
private function init() {
if ($this->initialized) {
if (!$this->storage) {
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
// 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;
}

Expand Down
Loading