-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
[stable28] fix: don't return null for SharedStorage::getWrapperStorage with share recursion #44323
Conversation
ec1c6f9
to
05d54cc
Compare
@icewind1991 Have you managed to run into this code path? I do not understand in which case can initialized be false and storage null at the same time. |
The process of getting the share source could lead to it recursing into the function if there (somehow) is a recursive share. This shouldn't happen but when it does this PR improves the error behavior |
Oh, thank you, I think I get it now. My first thought was moving |
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 = ''; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 = ''; | |
} | |
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 | |
throw new \Exception('Possible share setup recursion detected')]); | |
} |
This should work then, and it would be caught by the try/catch below?
Not sure if it’s cleaner because it would mean the function is now throwing.
There is a conflict on this one |
…e recursion Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
05d54cc
to
e0f3de8
Compare
Backport of #44132
Warning, This backport's changes differ from the original and might be incomplete⚠️
Todo
Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.