[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.
| 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 <[email protected]>
Signed-off-by: Robin Appelman <[email protected]>
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.