From 7e5c5cf681e49bdb21f13b5272a8c435a354f6c8 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 7 May 2026 17:40:19 +0200 Subject: [PATCH 1/2] perf: remove unneeded sort in getFolderContentsById Signed-off-by: Robin Appelman --- lib/private/Files/Cache/Cache.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index d14aac58850bd..7a811631a9a77 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -221,8 +221,7 @@ public function getFolderContentsById($fileId) { $query = $this->getQueryBuilder(); $query->selectFileCache() ->whereParent($fileId) - ->whereStorageId($this->getNumericStorageId()) - ->orderBy('name', 'ASC'); + ->whereStorageId($this->getNumericStorageId()); $metadataQuery = $query->selectMetadata(); From cfd63b8e41e85668813db67f1f9334011c0faf2b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 7 May 2026 18:50:14 +0200 Subject: [PATCH 2/2] test: adjust tests to unsorted folder listing Signed-off-by: Robin Appelman --- build/integration/features/bootstrap/Sharing.php | 8 +++++++- tests/lib/Files/ViewTest.php | 13 +++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/build/integration/features/bootstrap/Sharing.php b/build/integration/features/bootstrap/Sharing.php index 6b669720cb267..9b59db661f838 100644 --- a/build/integration/features/bootstrap/Sharing.php +++ b/build/integration/features/bootstrap/Sharing.php @@ -556,7 +556,13 @@ public function shareXIsReturnedWith(int $number, TableNode $body) { $returnedShare = $this->getXmlResponse()->data[0]; if ($returnedShare->element) { - $returnedShare = $returnedShare->element[$number]; + $returnedShare = (array)$returnedShare; + $returnedShare = $returnedShare['element']; + if (is_array($returnedShare)) { + usort($returnedShare, fn ($share1, $share2) => (int)$share1->id <=> (int)$share2->id); + } + + $returnedShare = $returnedShare[$number]; } $defaultExpectedFields = [ diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 72df3810f1909..806f678aa5114 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -209,6 +209,7 @@ public function testCacheAPI(): void { $this->assertEquals('httpd/unix-directory', $cachedData['mimetype']); $folderData = $rootView->getDirectoryContent('/'); + usort($folderData, fn (FileInfo $a, FileInfo $b) => $a->getName() <=> $b->getName()); /** * expected entries: * folder @@ -228,6 +229,7 @@ public function testCacheAPI(): void { $this->assertEquals($storageSize, $folderData[3]['size']); $folderData = $rootView->getDirectoryContent('/substorage'); + usort($folderData, fn (FileInfo $a, FileInfo $b) => $a->getName() <=> $b->getName()); /** * expected entries: * folder @@ -2812,11 +2814,13 @@ public function testMountpointParentsCreated(): void { $rootView = new View(''); $folderData = $rootView->getDirectoryContent('/'); + usort($folderData, fn (FileInfo $a, FileInfo $b) => $a->getName() <=> $b->getName()); $this->assertCount(4, $folderData); - $this->assertEquals('folder', $folderData[0]['name']); - $this->assertEquals('foo.png', $folderData[1]['name']); - $this->assertEquals('foo.txt', $folderData[2]['name']); - $this->assertEquals('A', $folderData[3]['name']); + + $this->assertEquals('A', $folderData[0]['name']); + $this->assertEquals('folder', $folderData[1]['name']); + $this->assertEquals('foo.png', $folderData[2]['name']); + $this->assertEquals('foo.txt', $folderData[3]['name']); $folderData = $rootView->getDirectoryContent('/A'); $this->assertCount(1, $folderData); @@ -2827,6 +2831,7 @@ public function testMountpointParentsCreated(): void { $this->assertEquals('C', $folderData[0]['name']); $folderData = $rootView->getDirectoryContent('/A/B/C'); + usort($folderData, fn (FileInfo $a, FileInfo $b) => $a->getName() <=> $b->getName()); $this->assertCount(3, $folderData); $this->assertEquals('folder', $folderData[0]['name']); $this->assertEquals('foo.png', $folderData[1]['name']);