Skip to content

Commit 1bae41c

Browse files
authored
Merge pull request #33709 from nextcloud/enh/displayname-cache-getStorageInfo
Use display name cache on getStorageInfo
2 parents 26e413b + 1746344 commit 1bae41c

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use OCA\DAV\Connector\Sabre\Directory;
3535
use OCP\Files\ForbiddenException;
3636
use OCP\Files\Mount\IMountPoint;
37+
use Test\Traits\UserTrait;
3738

3839
class TestViewDirectory extends \OC\Files\View {
3940
private $updatables;
@@ -73,6 +74,8 @@ public function getRelativePath($path) {
7374
*/
7475
class DirectoryTest extends \Test\TestCase {
7576

77+
use UserTrait;
78+
7679
/** @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject */
7780
private $view;
7881
/** @var \OC\Files\FileInfo | \PHPUnit\Framework\MockObject\MockObject */
@@ -274,6 +277,8 @@ public function testGetChildThrowInvalidPath() {
274277
}
275278

276279
public function testGetQuotaInfoUnlimited() {
280+
self::createUser('user', 'password');
281+
self::loginAsUser('user');
277282
$mountPoint = $this->createMock(IMountPoint::class);
278283
$storage = $this->getMockBuilder(Quota::class)
279284
->disableOriginalConstructor()
@@ -288,6 +293,10 @@ public function testGetQuotaInfoUnlimited() {
288293
'\OC\Files\Storage\Wrapper\Quota' => false,
289294
]);
290295

296+
$storage->expects($this->once())
297+
->method('getOwner')
298+
->willReturn('user');
299+
291300
$storage->expects($this->never())
292301
->method('getQuota');
293302

@@ -311,6 +320,8 @@ public function testGetQuotaInfoUnlimited() {
311320
}
312321

313322
public function testGetQuotaInfoSpecific() {
323+
self::createUser('user', 'password');
324+
self::loginAsUser('user');
314325
$mountPoint = $this->createMock(IMountPoint::class);
315326
$storage = $this->getMockBuilder(Quota::class)
316327
->disableOriginalConstructor()
@@ -325,6 +336,10 @@ public function testGetQuotaInfoSpecific() {
325336
['\OC\Files\Storage\Wrapper\Quota', true],
326337
]);
327338

339+
$storage->expects($this->once())
340+
->method('getOwner')
341+
->willReturn('user');
342+
328343
$storage->expects($this->once())
329344
->method('getQuota')
330345
->willReturn(1000);

lib/private/legacy/OC_Helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,10 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin
547547

548548
$ownerId = $storage->getOwner($path);
549549
$ownerDisplayName = '';
550-
$owner = \OC::$server->getUserManager()->get($ownerId);
551-
if ($owner) {
552-
$ownerDisplayName = $owner->getDisplayName();
550+
if ($ownerId) {
551+
$ownerDisplayName = \OC::$server->getUserManager()->getDisplayName($ownerId) ?? '';
553552
}
553+
554554
if (substr_count($mount->getMountPoint(), '/') < 3) {
555555
$mountPoint = '';
556556
} else {

0 commit comments

Comments
 (0)