Skip to content

Commit

Permalink
Merge pull request #1501 from nextcloud/dependaskjnldsv/1500/stable25
Browse files Browse the repository at this point in the history
[stable25] Fix version20003Date20221102170153 migration
  • Loading branch information
skjnldsv committed Nov 25, 2022
2 parents b9b0da3 + ffde138 commit c18728a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/Migration/Version20003Date20221102170153.php
Expand Up @@ -119,12 +119,13 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
protected function chunkedCopying(IQueryBuilder $insert, IQueryBuilder $select, int $offset): int {
$this->connection->beginTransaction();

$rowCount = 0;
$result = $select
->setFirstResult($offset)
->executeQuery();

while ($row = $result->fetch()) {
$insert
$rowCount += $insert
->setParameter('album_id', (int)$row['album_id'], IQueryBuilder::PARAM_INT)
->setParameter('collaborator_id', $row['collaborator_id'])
->setParameter('collaborator_type', (int) $row['collaborator_type'], IQueryBuilder::PARAM_INT)
Expand All @@ -134,6 +135,8 @@ protected function chunkedCopying(IQueryBuilder $insert, IQueryBuilder $select,
$result->closeCursor();
$this->connection->commit();

return $result->rowCount();
// $result->rowCount() cannot be relied on.
// some database drivers may return the number of rows returned by that query
return $rowCount;
}
}

0 comments on commit c18728a

Please sign in to comment.