Skip to content

Commit

Permalink
Merge pull request #44357 from nextcloud/wrapper-instanceof-resiliant
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Mar 22, 2024
2 parents ddb84f9 + 85b5dd0 commit fb97d55
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,16 @@ public function getSourceStorage() {

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;
}

Expand Down
9 changes: 9 additions & 0 deletions lib/private/Files/Storage/Wrapper/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand All @@ -60,6 +63,12 @@ public function __construct($parameters) {
* @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;
}

Expand Down

0 comments on commit fb97d55

Please sign in to comment.