Skip to content
Snippets Groups Projects
Commit 75a5e6e1 authored by Robin McCorkell's avatar Robin McCorkell
Browse files

Fix mounting wrapped storages resulting in many-layered wrapping

This usually doesn't cause issues, but in unit tests sometimes a wrapped
storage is passed to Filesystem::mount() and gets rewrapped, hitting the
XDebug function nesting level limit when used.
parent df19cabb
Branches
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ namespace OC\Files\Mount;
use \OC\Files\Filesystem;
use OC\Files\Storage\StorageFactory;
use OC\Files\Storage\Storage;
use OC\Files\Storage\Wrapper\Wrapper;
use OCP\Files\Mount\IMountPoint;
class MountPoint implements IMountPoint {
......@@ -92,7 +93,11 @@ class MountPoint implements IMountPoint {
$this->mountPoint = $mountpoint;
if ($storage instanceof Storage) {
$this->class = get_class($storage);
$this->storage = $this->loader->wrap($this, $storage);
$this->storage = $storage;
// only wrap if not already wrapped
if (!($this->storage instanceof Wrapper)) {
$this->storage = $this->loader->wrap($this, $this->storage);
}
} else {
// Update old classes to new namespace
if (strpos($storage, 'OC_Filestorage_') !== false) {
......
......@@ -70,4 +70,25 @@ class MountPoint extends \Test\TestCase {
// storage wrapper never called
$this->assertFalse($called);
}
public function testWrappedStorage() {
$storage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Wrapper')
->disableOriginalConstructor()
->getMock();
$loader = $this->getMock('\OCP\Files\Storage\IStorageFactory');
$loader->expects($this->never())
->method('getInstance');
$loader->expects($this->never())
->method('wrap');
$mountPoint = new \OC\Files\Mount\MountPoint(
$storage,
'/mountpoint',
null,
$loader
);
$this->assertEquals($storage, $mountPoint->getStorage());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment