diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index 67601f016be7c..90e431b3b30b6 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -196,11 +196,15 @@ public function getStorage() { } /** - * @return string + * @return string|null */ public function getStorageId() { if (!$this->storageId) { - $this->storageId = $this->getStorage()->getId(); + $storage = $this->getStorage(); + if (is_null($storage)) { + return null; + } + $this->storageId = $storage->getId(); if (strlen($this->storageId) > 64) { $this->storageId = md5($this->storageId); } @@ -209,11 +213,15 @@ public function getStorageId() { } /** - * @return int + * @return int|null */ public function getNumericStorageId() { if (is_null($this->numericStorageId)) { - $this->numericStorageId = $this->getStorage()->getStorageCache()->getNumericId(); + $storage = $this->getStorage(); + if (is_null($storage)) { + return null; + } + $this->numericStorageId = $storage->getStorageCache()->getNumericId(); } return $this->numericStorageId; } diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 2189e7c09f431..95d9a8e3051eb 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -1590,6 +1590,9 @@ private function createTestMovableMountPoints($mountPoints) { ->setConstructorArgs([[]]) ->getMock(); $storage->method('getId')->willReturn('non-null-id'); + $storage->method('getStorageCache')->willReturnCallback(function () use ($storage) { + return new \OC\Files\Cache\Storage($storage); + }); $mounts[] = $this->getMockBuilder(TestMoveableMountPoint::class) ->setMethods(['moveMount'])