From 92eab9abb156640747b0ddc7ca3add50c42c3b49 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 463cb19482..97e854a4bf 100644 --- a/src/Commands/core/QueueCommands.php +++ b/src/Commands/core/QueueCommands.php @@ -98,7 +98,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 { @@ -134,7 +137,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)])); }