Skip to content

Commit 1ea8942

Browse files
dd32claude
andcommitted
Fix elapsed time continuing to count after task completion
The elapsed time display used microtime(true) for all tasks, causing finished tasks to show an ever-increasing duration. Now uses the stored end_time for completed tasks so the timer freezes at the actual completion moment. Bumps version to 1.0.1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent edf31a3 commit 1ea8942

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"type": "wp-cli-package",
55
"keywords": ["wp-cli", "cron", "concurrent"],
66
"license": "MIT",
7+
"version": "1.0.1",
78
"require": {
89
"wp-cli/wp-cli": "^2.0"
910
},

cron-concurrent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Plugin Name: WP-CLI Cron Concurrent
44
* Description: Runs WordPress cron tasks concurrently via wp-cli.
5-
* Version: 1.0.0
5+
* Version: 1.0.1
66
* Author: dd32
77
* License: MIT
88
*/

src/CronConcurrent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ private function render( array $running, array $finished, int $lines_printed, bo
302302
* @param bool $running True if the task is still running.
303303
*/
304304
private function print_row( array $handle, bool $running ): void {
305-
$elapsed = microtime( true ) - $handle['start_time'];
305+
$end = $handle['end_time'] ?? microtime( true );
306+
$elapsed = $end - $handle['start_time'];
306307

307308
if ( $running ) {
308309
$indicator = $this->spinner( $handle['start_time'] ) . " \033[33mRunning \033[0m";

0 commit comments

Comments
 (0)