From fc34c392492d0574ebfada0d30b5381d8b21799b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20K=C3=A4mper-Leymann?= Date: Tue, 15 Mar 2022 11:26:00 +0100 Subject: [PATCH] Fix progress bar 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`. --- src/Drupal/Commands/core/EntityCommands.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Drupal/Commands/core/EntityCommands.php b/src/Drupal/Commands/core/EntityCommands.php index f00ea8b825..06b80ebd1d 100644 --- a/src/Drupal/Commands/core/EntityCommands.php +++ b/src/Drupal/Commands/core/EntityCommands.php @@ -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))])); @@ -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))]));