aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2023-01-06 08:58:48 +0100
committerGitHub <noreply@github.com>2023-01-06 08:58:48 +0100
commit264df536403929ef5ecf036552e5277d8b0c3e19 (patch)
tree832199ab201a518f16b3d330af4d9dfa25a2f79f
parent317c07f7c67b530888405d0791054021ab4e154c (diff)
parent41fb0682b22649d45f04e556f9784ad715ce4b52 (diff)
downloadnextcloud-server-264df536403929ef5ecf036552e5277d8b0c3e19.tar.gz
nextcloud-server-264df536403929ef5ecf036552e5277d8b0c3e19.zip
Merge pull request #35815 from nextcloud/backport/33709/stable25
[stable25] Use display name cache on getStorageInfo
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php15
-rw-r--r--lib/private/legacy/OC_Helper.php6
2 files changed, 18 insertions, 3 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
index e8297c2ac66..1de82484ac4 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
@@ -34,6 +34,7 @@ use OC\Files\Storage\Wrapper\Quota;
use OCA\DAV\Connector\Sabre\Directory;
use OCP\Files\ForbiddenException;
use OCP\Files\Mount\IMountPoint;
+use Test\Traits\UserTrait;
class TestViewDirectory extends \OC\Files\View {
private $updatables;
@@ -73,6 +74,8 @@ class TestViewDirectory extends \OC\Files\View {
*/
class DirectoryTest extends \Test\TestCase {
+ use UserTrait;
+
/** @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject */
private $view;
/** @var \OC\Files\FileInfo | \PHPUnit\Framework\MockObject\MockObject */
@@ -274,6 +277,8 @@ class DirectoryTest extends \Test\TestCase {
}
public function testGetQuotaInfoUnlimited() {
+ self::createUser('user', 'password');
+ self::loginAsUser('user');
$mountPoint = $this->createMock(IMountPoint::class);
$storage = $this->getMockBuilder(Quota::class)
->disableOriginalConstructor()
@@ -288,6 +293,10 @@ class DirectoryTest extends \Test\TestCase {
'\OC\Files\Storage\Wrapper\Quota' => false,
]);
+ $storage->expects($this->once())
+ ->method('getOwner')
+ ->willReturn('user');
+
$storage->expects($this->never())
->method('getQuota');
@@ -311,6 +320,8 @@ class DirectoryTest extends \Test\TestCase {
}
public function testGetQuotaInfoSpecific() {
+ self::createUser('user', 'password');
+ self::loginAsUser('user');
$mountPoint = $this->createMock(IMountPoint::class);
$storage = $this->getMockBuilder(Quota::class)
->disableOriginalConstructor()
@@ -326,6 +337,10 @@ class DirectoryTest extends \Test\TestCase {
]);
$storage->expects($this->once())
+ ->method('getOwner')
+ ->willReturn('user');
+
+ $storage->expects($this->once())
->method('getQuota')
->willReturn(1000);
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index de42a7bc7fc..5ee6ec69ac2 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -547,10 +547,10 @@ class OC_Helper {
$ownerId = $storage->getOwner($path);
$ownerDisplayName = '';
- $owner = \OC::$server->getUserManager()->get($ownerId);
- if ($owner) {
- $ownerDisplayName = $owner->getDisplayName();
+ if ($ownerId) {
+ $ownerDisplayName = \OC::$server->getUserManager()->getDisplayName($ownerId) ?? '';
}
+
if (substr_count($mount->getMountPoint(), '/') < 3) {
$mountPoint = '';
} else {