Skip to content

Commit 4ac0fcf

Browse files
committed
fix: check instance of storage using helper function
instanceof cannot be used to check the instance of a storage, doing so breaks the check in certain cases. In this case, enabling the `files_accesscontrol` app breaks the check. Signed-off-by: Salvatore Martire <[email protected]>
1 parent 38f8423 commit 4ac0fcf

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

apps/dav/lib/Connector/Sabre/Directory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function getChild($name, $info = null, ?IRequest $request = null, ?IL10N
181181
// If we are, then only PUT and MKCOL are allowed (see plugin)
182182
// so we are safe to return the directory without a risk of
183183
// leaking files and folders structure.
184-
if ($storage instanceof PublicShareWrapper) {
184+
if ($storage->instanceOfStorage(PublicShareWrapper::class)) {
185185
$share = $storage->getShare();
186186
$allowDirectory = ($share->getPermissions() & Constants::PERMISSION_READ) !== Constants::PERMISSION_READ;
187187
}

apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use OCP\Files\ForbiddenException;
2222
use OCP\Files\InvalidPathException;
2323
use OCP\Files\Mount\IMountPoint;
24+
use OCP\Files\Storage\IStorage;
2425
use OCP\Files\StorageNotAvailableException;
2526
use PHPUnit\Framework\MockObject\MockObject;
2627
use Test\Traits\UserTrait;
@@ -61,12 +62,16 @@ class DirectoryTest extends \Test\TestCase {
6162

6263
private View&MockObject $view;
6364
private FileInfo&MockObject $info;
65+
private IStorage&MockObject $storage;
6466

6567
protected function setUp(): void {
6668
parent::setUp();
6769

6870
$this->view = $this->createMock(View::class);
6971
$this->info = $this->createMock(FileInfo::class);
72+
$this->storage = $this->createMock(IStorage::class);
73+
$this->info->method('getStorage')
74+
->willReturn($this->storage);
7075
$this->info->method('isReadable')
7176
->willReturn(true);
7277
$this->info->method('getType')

0 commit comments

Comments
 (0)