fix: Backport to 30

Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
Louis Chemineau 2024-08-28 12:28:50 +02:00 committed by Louis
parent e5a8f996bd
commit 140b36fcea
3 changed files with 16 additions and 12 deletions

View file

@ -48,16 +48,10 @@ class DeleteOrphanedFiles extends Command {
$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");

View file

@ -1365,4 +1365,14 @@ class QueryBuilder implements IQueryBuilder {
return $this->helper->quoteColumnName($alias);
}
public function hintShardKey(string $column, mixed $value, bool $overwrite = false) {
return $this;
}
public function runAcrossAllShards() {
// noop
return $this;
}
}

View file

@ -142,7 +142,7 @@ class CleanTagsTest extends \Test\TestCase {
])
->execute();
return (int) $this->getLastInsertID('vcategory', 'id');
return $qb->getLastInsertId();
}
/**
@ -191,7 +191,7 @@ class CleanTagsTest extends \Test\TestCase {
])
->execute();
$this->createdFile = (int) $this->getLastInsertID('filecache', 'fileid');
$this->createdFile = $qb->getLastInsertId();
return $this->createdFile;
}
}