Skip to content

Commit

Permalink
Correct fix for batch update scenario (#5809)
Browse files Browse the repository at this point in the history
  • Loading branch information
Berdir authored Nov 13, 2023
1 parent 3652155 commit 4e65298
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions includes/batch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,20 @@ function _drush_backend_batch_process($command = 'batch-process', $args = [], $o
$batch['id'] = $batch_storage->getId();
}
catch (IntegrityConstraintViolationException) {
// Remove calls to nextId() once 10.0 is no longer supported.
$batch['id'] = \Drupal::database()->nextId();
// @todo this is here to support the update path to deprecate
// Connection::nextId(). Remove when Drupal 10.1 and lower is no longer
// supported.
$connection = \Drupal::database();
$max_bid = (int) $connection->query('SELECT MAX([bid]) FROM {batch}')->fetchField();
$batch['id'] = $max_bid + 1;
$connection->insert('batch')
->fields([
'bid' => $batch['id'],
'timestamp' => \Drupal::time()->getRequestTime(),
'token' => '',
'batch' => NULL,
])
->execute();
}
}
else {
Expand Down

0 comments on commit 4e65298

Please sign in to comment.