Skip to content

Commit

Permalink
fix: Backport to 30
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Aug 28, 2024
1 parent e5a8f99 commit 140b36f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
14 changes: 4 additions & 10 deletions apps/files/lib/Command/DeleteOrphanedFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
10 changes: 10 additions & 0 deletions lib/private/DB/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
4 changes: 2 additions & 2 deletions tests/lib/Repair/CleanTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function addTagCategory($category, $type, $user = 'TestRepairCleanTags
])
->execute();

return (int) $this->getLastInsertID('vcategory', 'id');
return $qb->getLastInsertId();
}

/**
Expand Down Expand Up @@ -191,7 +191,7 @@ protected function getFileID() {
])
->execute();

$this->createdFile = (int) $this->getLastInsertID('filecache', 'fileid');
$this->createdFile = $qb->getLastInsertId();
return $this->createdFile;
}
}

0 comments on commit 140b36f

Please sign in to comment.