diff options
author | Robin Appelman <robin@icewind.nl> | 2016-08-22 15:12:39 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2016-08-23 14:52:18 +0200 |
commit | a0c2342c20d874a87335a3e1c21bbfa05a71a776 (patch) | |
tree | de17cd95db017e85e1a25f4a327beb045569392e /lib | |
parent | 1e7c108bff45dfa5081fe6c5ec6115fe8c8d699a (diff) | |
download | nextcloud-server-a0c2342c20d874a87335a3e1c21bbfa05a71a776.tar.gz nextcloud-server-a0c2342c20d874a87335a3e1c21bbfa05a71a776.zip |
prevent infinite recursion while getting storage from mount
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Mount/MountPoint.php | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index 8b8f0574ae0..4aef340149c 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -70,7 +70,7 @@ class MountPoint implements IMountPoint { */ private $invalidStorage = false; - /** @var int|null */ + /** @var int|null */ protected $mountId; /** @@ -132,18 +132,20 @@ class MountPoint implements IMountPoint { /** * create the storage that is mounted - * - * @return \OC\Files\Storage\Storage */ private function createStorage() { if ($this->invalidStorage) { - return null; + return; } if (class_exists($this->class)) { try { - return $this->loader->getInstance($this, $this->class, $this->arguments); + $class = $this->class; + // prevent recursion by setting the storage before applying wrappers + $this->storage = new $class($this->arguments); + $this->storage = $this->loader->wrap($this, $this->storage); } catch (\Exception $exception) { + $this->storage = null; $this->invalidStorage = true; if ($this->mountPoint === '/') { // the root storage could not be initialized, show the user! @@ -151,12 +153,12 @@ class MountPoint implements IMountPoint { } else { \OCP\Util::writeLog('core', $exception->getMessage(), \OCP\Util::ERROR); } - return null; + return; } } else { \OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', \OCP\Util::ERROR); $this->invalidStorage = true; - return null; + return; } } @@ -165,7 +167,7 @@ class MountPoint implements IMountPoint { */ public function getStorage() { if (is_null($this->storage)) { - $this->storage = $this->createStorage(); + $this->createStorage(); } return $this->storage; } |