Skip to content

Commit f3ae8ab

Browse files
authored
Merge pull request #59902 from nextcloud/preload-storage-chukn
fix: chunk storage ids when preload storage info
2 parents d7a6e03 + 5c1a72a commit f3ae8ab

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

apps/dav/lib/Migration/Version1039Date20260408000000.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#[AddColumn(table: 'calendars', name: 'default_alarm_pday', type: ColumnType::INTEGER)]
2323
#[AddColumn(table: 'calendars', name: 'default_alarm_fday', type: ColumnType::INTEGER)]
2424
class Version1039Date20260408000000 extends SimpleMigrationStep {
25+
#[\Override]
2526
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
2627
/** @var ISchemaWrapper $schema */
2728
$schema = $schemaClosure();

lib/private/Files/Cache/StorageGlobal.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,23 @@ public function loadForStorageIds(array $storageIds): void {
4242
$builder = $this->connection->getQueryBuilder();
4343
$query = $builder->select(['id', 'numeric_id', 'available', 'last_checked'])
4444
->from('storages')
45-
->where($builder->expr()->in('id', $builder->createNamedParameter(array_values($storageIds), IQueryBuilder::PARAM_STR_ARRAY)));
46-
47-
$result = $query->executeQuery();
48-
while (($row = $result->fetch()) !== false) {
49-
$normalizedRow = [
50-
'id' => (string)$row['id'],
51-
'numeric_id' => (int)$row['numeric_id'],
52-
'available' => (bool)$row['available'],
53-
'last_checked' => (int)$row['last_checked'],
54-
];
55-
56-
$this->cache[$normalizedRow['id']] = $normalizedRow;
57-
}
45+
->where($builder->expr()->in('id', $builder->createParameter('ids'), IQueryBuilder::PARAM_STR_ARRAY));
46+
47+
foreach (array_chunk($storageIds, 1000) as $chunk) {
48+
$query->setParameter('ids', $chunk, IQueryBuilder::PARAM_STR_ARRAY);
5849

59-
$result->closeCursor();
50+
$result = $query->executeQuery();
51+
while (($row = $result->fetch()) !== false) {
52+
$normalizedRow = [
53+
'id' => (string)$row['id'],
54+
'numeric_id' => (int)$row['numeric_id'],
55+
'available' => (bool)$row['available'],
56+
'last_checked' => (int)$row['last_checked'],
57+
];
58+
59+
$this->cache[$normalizedRow['id']] = $normalizedRow;
60+
}
61+
}
6062
}
6163

6264
/**

0 commit comments

Comments
 (0)