diff options
author | Robin Appelman <robin@icewind.nl> | 2024-03-20 14:09:58 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-03-20 14:50:06 +0100 |
commit | 9230bfebccb866c62caeaf13668639828e1585d8 (patch) | |
tree | 9b42b2a78b6d2360e768895012b83c46ff789346 | |
parent | c451829579de14fbae33b9f59075a025471066c6 (diff) | |
download | nextcloud-server-wrapper-instanceof-resiliant-squash.tar.gz nextcloud-server-wrapper-instanceof-resiliant-squash.zip |
fix: log error when default getWrapperStorage would return nullwrapper-instanceof-resiliant-squash
Signed-off-by: Robin Appelman <robin@icewind.nl>
fix: add extra check to ensure wrapped shared storage is set
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | apps/files_sharing/lib/SharedStorage.php | 10 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Wrapper.php | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 877de247fb1..d5c264def3b 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -569,6 +569,16 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto public function getWrapperStorage() { $this->init(); + + /** + * @psalm-suppress DocblockTypeContradiction + */ + if (!$this->storage) { + $message = "no storage set after init for share " . $this->getShareId(); + $this->logger->error($message); + $this->storage = new FailedStorage(['exception' => new \Exception($message)]); + } + return $this->storage; } diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index 665914df2a7..2c50bbdb11f 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -31,11 +31,14 @@ */ namespace OC\Files\Storage\Wrapper; +use OC\Files\Storage\FailedStorage; use OCP\Files\InvalidPathException; use OCP\Files\Storage\ILockingStorage; use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IWriteStreamStorage; use OCP\Lock\ILockingProvider; +use OCP\Server; +use Psr\Log\LoggerInterface; class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStreamStorage { /** @@ -60,6 +63,12 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea * @return \OC\Files\Storage\Storage */ public function getWrapperStorage() { + if (!$this->storage) { + $message = "storage wrapper " . get_class($this) . " doesn't have a wrapped storage set"; + $logger = Server::get(LoggerInterface::class); + $logger->error($message); + $this->storage = new FailedStorage(['exception' => new \Exception($message)]); + } return $this->storage; } |