Skip to content

Commit

Permalink
Fix progress bar (#5096)
Browse files Browse the repository at this point in the history
Let's assume there are only 5 entities, but chunk size is set as 250. The progress bar shows "5" => "0%" for one second and immediately switch to "250" => "100%". While the progress should only rise by the actual number of entity IDs in the current `$chunk`.
  • Loading branch information
leymannx committed Mar 15, 2022
1 parent 3f45eb0 commit 287400c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Drupal/Commands/core/EntityCommands.php
Expand Up @@ -67,7 +67,7 @@ public function delete(string $entity_type, $ids = null, array $options = ['bund
$this->io()->progressStart(count($result));
foreach (array_chunk($result, $options['chunks'], true) as $chunk) {
drush_op([$this, 'doDelete'], $entity_type, $chunk);
$this->io()->progressAdvance($options['chunks']);
$this->io()->progressAdvance(count($chunk));
}
$this->io()->progressFinish();
$this->logger()->success(dt("Deleted !type entity Ids: !ids", ['!type' => $entity_type, '!ids' => implode(', ', array_values($result))]));
Expand Down Expand Up @@ -130,7 +130,7 @@ public function loadSave(string $entity_type, $ids = null, array $options = ['bu
$this->io()->progressStart(count($result));
foreach (array_chunk($result, $options['chunks'], true) as $chunk) {
drush_op([$this, 'doSave'], $entity_type, $chunk);
$this->io()->progressAdvance($options['chunks']);
$this->io()->progressAdvance(count($chunk));
}
$this->io()->progressFinish();
$this->logger()->success(dt("Saved !type entity ids: !ids", ['!type' => $entity_type, '!ids' => implode(', ', array_values($result))]));
Expand Down

0 comments on commit 287400c

Please sign in to comment.