From 398ea655e0d1eeafd8458034ec4f622c93818396 Mon Sep 17 00:00:00 2001 From: Ben Croker <57572400+bencroker@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:48:13 -0600 Subject: [PATCH] Update BaseBatchedJob.php --- src/queue/BaseBatchedJob.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/queue/BaseBatchedJob.php b/src/queue/BaseBatchedJob.php index 513750f3831..8637f9dbc7b 100644 --- a/src/queue/BaseBatchedJob.php +++ b/src/queue/BaseBatchedJob.php @@ -115,7 +115,6 @@ final protected function totalBatches(): int public function execute($queue): void { $items = $this->data()->getSlice($this->itemOffset, $this->batchSize); - $totalInBatch = is_array($items) ? count($items) : iterator_count($items); $memoryLimit = ConfigHelper::sizeInBytes(ini_get('memory_limit')); $startMemory = $memoryLimit != -1 ? memory_get_usage() : null; @@ -129,9 +128,11 @@ public function execute($queue): void $i = 0; foreach ($items as $item) { - $this->setProgress($queue, $i / $totalInBatch, Translation::prep('app', '{step, number} of {total, number}', [ - 'step' => $this->itemOffset + 1, - 'total' => $this->totalItems(), + $step = $this->itemOffset + 1; + $total = $this->totalItems(); + $this->setProgress($queue, $step / $total, Translation::prep('app', '{step, number} of {total, number}', [ + 'step' => $step, + 'total' => $total, ])); $this->processItem($item); $this->itemOffset++;