From 06c625f20cdb61d577aa636cefdfcccfa59c5f35 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 cee84b9c8c6b0..19347d50e7590 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -218,8 +218,7 @@ public function getFolderContentsById(int $fileId, ?string $mimeTypeFilter = nul $query = $this->getQueryBuilder(); $query->selectFileCache() ->whereParent($fileId) - ->whereStorageId($this->getNumericStorageId()) - ->orderBy('name', 'ASC'); + ->whereStorageId($this->getNumericStorageId()); if ($mimeTypeFilter !== null) { $mimetype = $this->mimetypeLoader->getId($mimeTypeFilter); From c91f8b0e2cbcefa06798832ab04be52e610af421 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 4a12fbe5cc43a..98ecce66832a8 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 3169edf0b0f18..feb7800c12845 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -215,6 +215,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 @@ -234,6 +235,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 @@ -2817,11 +2819,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); @@ -2832,6 +2836,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']);