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 516437c commit 066d5fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 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
21 changes: 15 additions & 6 deletions lib/private/DB/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public function __construct(ConnectionAdapter $connection, SystemConfig $systemC
* Enable/disable automatic prefixing of table names with the oc_ prefix
*
* @param bool $enabled If set to true table names will be prefixed with the
* owncloud database prefix automatically.
* owncloud database prefix automatically.
* @since 8.2.0
*/
public function automaticTablePrefix($enabled) {
$this->automaticTablePrefix = (bool) $enabled;
$this->automaticTablePrefix = (bool)$enabled;
}

/**
Expand Down Expand Up @@ -406,7 +406,7 @@ public function getParameterType($key) {
* @return $this This QueryBuilder instance.
*/
public function setFirstResult($firstResult) {
$this->queryBuilder->setFirstResult((int) $firstResult);
$this->queryBuilder->setFirstResult((int)$firstResult);

return $this;
}
Expand Down Expand Up @@ -436,7 +436,7 @@ public function setMaxResults($maxResults) {
if ($maxResults === null) {
$this->queryBuilder->setMaxResults($maxResults);
} else {
$this->queryBuilder->setMaxResults((int) $maxResults);
$this->queryBuilder->setMaxResults((int)$maxResults);
}

return $this;
Expand Down Expand Up @@ -1007,7 +1007,7 @@ public function addGroupBy(...$groupBy) {
public function setValue($column, $value) {
$this->queryBuilder->setValue(
$this->helper->quoteColumnName($column),
(string) $value
(string)$value
);

return $this;
Expand Down Expand Up @@ -1316,7 +1316,7 @@ public function getLastInsertId(): int {
*/
public function getTableName($table) {
if ($table instanceof IQueryFunction) {
return (string) $table;
return (string)$table;
}

$table = $this->prefixTableName($table);
Expand Down Expand Up @@ -1365,4 +1365,13 @@ 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;
}
}

0 comments on commit 066d5fb

Please sign in to comment.