Skip to content

Commit d558eda

Browse files
Copilotswissspidy
andcommitted
Use standard doing_cron transient with plain numeric microtime value
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent d795834 commit d558eda

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

features/cron-event.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ Feature: Manage WP Cron events
252252
Success: Scheduled event with hook 'wp_cli_test_event_lock'
253253
"""
254254

255-
# Simulate an in-progress WP-CLI cron run by setting the wp_cli_doing_cron transient.
256-
When I run `wp eval 'set_transient( "wp_cli_doing_cron", sprintf( "%.22F", microtime( true ) ) );'`
255+
# Simulate an in-progress cron run by setting the doing_cron transient.
256+
When I run `wp eval 'set_transient( "doing_cron", sprintf( "%.22F", microtime( true ) ) );'`
257257

258258
And I try `wp cron event run --due-now`
259259
Then STDERR should contain:
@@ -266,7 +266,7 @@ Feature: Manage WP Cron events
266266
"""
267267

268268
# After the transient is cleared, the run should proceed normally.
269-
When I run `wp eval 'delete_transient( "wp_cli_doing_cron" );'`
269+
When I run `wp eval 'delete_transient( "doing_cron" );'`
270270
And I try `wp cron event run --due-now`
271271
Then STDOUT should contain:
272272
"""

src/Cron_Event_Command.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,19 +248,19 @@ public function run( $args, $assoc_args ) {
248248

249249
if ( $due_now ) {
250250
$lock_timeout = defined( 'WP_CRON_LOCK_TIMEOUT' ) ? WP_CRON_LOCK_TIMEOUT : 60;
251-
$doing_cron_transient = get_transient( 'wp_cli_doing_cron' );
251+
$doing_cron_transient = get_transient( 'doing_cron' );
252252
if ( is_numeric( $doing_cron_transient ) && (float) $doing_cron_transient > microtime( true ) - $lock_timeout ) {
253253
WP_CLI::warning( 'A cron event run is already in progress; skipping.' );
254254
return;
255255
}
256-
set_transient( 'wp_cli_doing_cron', sprintf( '%.22F', microtime( true ) ) );
256+
set_transient( 'doing_cron', sprintf( '%.22F', microtime( true ) ) );
257257
}
258258

259259
$events = self::get_selected_cron_events( $args, $assoc_args );
260260

261261
if ( is_wp_error( $events ) ) {
262262
if ( $due_now ) {
263-
delete_transient( 'wp_cli_doing_cron' );
263+
delete_transient( 'doing_cron' );
264264
}
265265
WP_CLI::error( $events );
266266
}
@@ -279,7 +279,7 @@ public function run( $args, $assoc_args ) {
279279
}
280280

281281
if ( $due_now ) {
282-
delete_transient( 'wp_cli_doing_cron' );
282+
delete_transient( 'doing_cron' );
283283
}
284284

285285
$message = ( 1 === $executed ) ? 'Executed a total of %d cron event.' : 'Executed a total of %d cron events.';

0 commit comments

Comments
 (0)