From 06e36ddf886907b4f818cd2f05c95cb75eb561cf Mon Sep 17 00:00:00 2001 From: Dieter Holvoet Date: Mon, 6 May 2024 21:59:36 +0200 Subject: [PATCH] Only start progress bar if any queue items --- src/Commands/core/QueueCommands.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Commands/core/QueueCommands.php b/src/Commands/core/QueueCommands.php index f99383f1e4..e181574378 100644 --- a/src/Commands/core/QueueCommands.php +++ b/src/Commands/core/QueueCommands.php @@ -74,7 +74,10 @@ public function run(string $name, $options = ['time-limit' => self::REQ, 'items- $queue->garbageCollection(); } - $this->io()->progressStart($items_limit ?: $queue->numberOfItems()); + $max = $items_limit ?: $queue->numberOfItems(); + if ($max > 0) { + $this->io()->progressStart($max); + } while ((!$time_limit || $remaining > 0) && (!$items_limit || $count < $items_limit) && ($item = $queue->claimItem($lease_time))) { try { @@ -112,7 +115,9 @@ public function run(string $name, $options = ['time-limit' => self::REQ, 'items- $remaining = $end - time(); } $elapsed = microtime(true) - $start; - $this->io()->progressFinish(); + if ($max > 0) { + $this->io()->progressFinish(); + } $this->logger()->success(dt('Processed @count items from the @name queue in @elapsed sec.', ['@count' => $count, '@name' => $name, '@elapsed' => round($elapsed, 2)])); }