Skip to content

Commit 066d5fb

Browse files
committed
fix: Backport to 30
Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent 516437c commit 066d5fb

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

apps/files/lib/Command/DeleteOrphanedFiles.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,10 @@ public function execute(InputInterface $input, OutputInterface $output): int {
4848
$deleteQuery->delete('filecache')
4949
->where($deleteQuery->expr()->in('storage', $deleteQuery->createParameter('storage_ids')));
5050

51-
$deletedInLastChunk = self::CHUNK_SIZE;
52-
while ($deletedInLastChunk === self::CHUNK_SIZE) {
53-
$deletedInLastChunk = 0;
54-
$result = $query->execute();
55-
while ($row = $result->fetch()) {
56-
$deletedInLastChunk++;
57-
$deletedEntries += $deleteQuery->setParameter('objectid', (int) $row['fileid'])
58-
->execute();
59-
}
60-
$result->closeCursor();
51+
$deletedStorageChunks = array_chunk($deletedStorages, self::CHUNK_SIZE);
52+
foreach ($deletedStorageChunks as $deletedStorageChunk) {
53+
$deleteQuery->setParameter('storage_ids', $deletedStorageChunk, IQueryBuilder::PARAM_INT_ARRAY);
54+
$deletedEntries += $deleteQuery->executeStatement();
6155
}
6256

6357
$output->writeln("$deletedEntries orphaned file cache entries deleted");

lib/private/DB/QueryBuilder/QueryBuilder.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ public function __construct(ConnectionAdapter $connection, SystemConfig $systemC
6969
* Enable/disable automatic prefixing of table names with the oc_ prefix
7070
*
7171
* @param bool $enabled If set to true table names will be prefixed with the
72-
* owncloud database prefix automatically.
72+
* owncloud database prefix automatically.
7373
* @since 8.2.0
7474
*/
7575
public function automaticTablePrefix($enabled) {
76-
$this->automaticTablePrefix = (bool) $enabled;
76+
$this->automaticTablePrefix = (bool)$enabled;
7777
}
7878

7979
/**
@@ -406,7 +406,7 @@ public function getParameterType($key) {
406406
* @return $this This QueryBuilder instance.
407407
*/
408408
public function setFirstResult($firstResult) {
409-
$this->queryBuilder->setFirstResult((int) $firstResult);
409+
$this->queryBuilder->setFirstResult((int)$firstResult);
410410

411411
return $this;
412412
}
@@ -436,7 +436,7 @@ public function setMaxResults($maxResults) {
436436
if ($maxResults === null) {
437437
$this->queryBuilder->setMaxResults($maxResults);
438438
} else {
439-
$this->queryBuilder->setMaxResults((int) $maxResults);
439+
$this->queryBuilder->setMaxResults((int)$maxResults);
440440
}
441441

442442
return $this;
@@ -1007,7 +1007,7 @@ public function addGroupBy(...$groupBy) {
10071007
public function setValue($column, $value) {
10081008
$this->queryBuilder->setValue(
10091009
$this->helper->quoteColumnName($column),
1010-
(string) $value
1010+
(string)$value
10111011
);
10121012

10131013
return $this;
@@ -1316,7 +1316,7 @@ public function getLastInsertId(): int {
13161316
*/
13171317
public function getTableName($table) {
13181318
if ($table instanceof IQueryFunction) {
1319-
return (string) $table;
1319+
return (string)$table;
13201320
}
13211321

13221322
$table = $this->prefixTableName($table);
@@ -1365,4 +1365,13 @@ public function quoteAlias($alias) {
13651365

13661366
return $this->helper->quoteColumnName($alias);
13671367
}
1368+
1369+
public function hintShardKey(string $column, mixed $value, bool $overwrite = false) {
1370+
return $this;
1371+
}
1372+
1373+
public function runAcrossAllShards() {
1374+
// noop
1375+
return $this;
1376+
}
13681377
}

0 commit comments

Comments
 (0)