From 140b36fcea956b149b25d1fbd3fc961a20b819eb Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 28 Aug 2024 12:28:50 +0200 Subject: [PATCH] fix: Backport to 30 Signed-off-by: Louis Chemineau --- apps/files/lib/Command/DeleteOrphanedFiles.php | 14 ++++---------- lib/private/DB/QueryBuilder/QueryBuilder.php | 10 ++++++++++ tests/lib/Repair/CleanTagsTest.php | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/apps/files/lib/Command/DeleteOrphanedFiles.php b/apps/files/lib/Command/DeleteOrphanedFiles.php index 8f93242b255b9..047e26f11eca7 100644 --- a/apps/files/lib/Command/DeleteOrphanedFiles.php +++ b/apps/files/lib/Command/DeleteOrphanedFiles.php @@ -48,16 +48,10 @@ public function execute(InputInterface $input, OutputInterface $output): int { $deleteQuery->delete('filecache') ->where($deleteQuery->expr()->in('storage', $deleteQuery->createParameter('storage_ids'))); - $deletedInLastChunk = self::CHUNK_SIZE; - while ($deletedInLastChunk === self::CHUNK_SIZE) { - $deletedInLastChunk = 0; - $result = $query->execute(); - while ($row = $result->fetch()) { - $deletedInLastChunk++; - $deletedEntries += $deleteQuery->setParameter('objectid', (int) $row['fileid']) - ->execute(); - } - $result->closeCursor(); + $deletedStorageChunks = array_chunk($deletedStorages, self::CHUNK_SIZE); + foreach ($deletedStorageChunks as $deletedStorageChunk) { + $deleteQuery->setParameter('storage_ids', $deletedStorageChunk, IQueryBuilder::PARAM_INT_ARRAY); + $deletedEntries += $deleteQuery->executeStatement(); } $output->writeln("$deletedEntries orphaned file cache entries deleted"); diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index 912d48cd34ece..ec2581d7e9a8b 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -1365,4 +1365,14 @@ public function quoteAlias($alias) { return $this->helper->quoteColumnName($alias); } + + public function hintShardKey(string $column, mixed $value, bool $overwrite = false) { + return $this; + } + + public function runAcrossAllShards() { + // noop + return $this; + } + } diff --git a/tests/lib/Repair/CleanTagsTest.php b/tests/lib/Repair/CleanTagsTest.php index 80c0b2c9770a4..11430cc121550 100644 --- a/tests/lib/Repair/CleanTagsTest.php +++ b/tests/lib/Repair/CleanTagsTest.php @@ -142,7 +142,7 @@ protected function addTagCategory($category, $type, $user = 'TestRepairCleanTags ]) ->execute(); - return (int) $this->getLastInsertID('vcategory', 'id'); + return $qb->getLastInsertId(); } /** @@ -191,7 +191,7 @@ protected function getFileID() { ]) ->execute(); - $this->createdFile = (int) $this->getLastInsertID('filecache', 'fileid'); + $this->createdFile = $qb->getLastInsertId(); return $this->createdFile; } }