@@ -248,27 +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 ( 'doing_cron ' );
252- // Only treat the lock as belonging to another WP-CLI run when WP-CLI
253- // itself set it (value starts with 'wpcli_'). WordPress's spawn_cron()
254- // always stores a plain numeric microtime string, so we must not block
255- // ourselves on a transient that was set by spawn_cron during bootstrap.
256- if (
257- is_string ( $ doing_cron_transient ) &&
258- 0 === strncmp ( $ doing_cron_transient , 'wpcli_ ' , 6 ) &&
259- (float ) substr ( $ doing_cron_transient , 6 ) > microtime ( true ) - $ lock_timeout
260- ) {
251+ $ doing_cron_transient = get_transient ( 'wp_cli_doing_cron ' );
252+ if ( is_numeric ( $ doing_cron_transient ) && (float ) $ doing_cron_transient > microtime ( true ) - $ lock_timeout ) {
261253 WP_CLI ::warning ( 'A cron event run is already in progress; skipping. ' );
262254 return ;
263255 }
264- set_transient ( 'doing_cron ' , ' wpcli_ ' . sprintf ( '%.22F ' , microtime ( true ) ) );
256+ set_transient ( 'wp_cli_doing_cron ' , sprintf ( '%.22F ' , microtime ( true ) ) );
265257 }
266258
267259 $ events = self ::get_selected_cron_events ( $ args , $ assoc_args );
268260
269261 if ( is_wp_error ( $ events ) ) {
270262 if ( $ due_now ) {
271- delete_transient ( 'doing_cron ' );
263+ delete_transient ( 'wp_cli_doing_cron ' );
272264 }
273265 WP_CLI ::error ( $ events );
274266 }
@@ -287,7 +279,7 @@ public function run( $args, $assoc_args ) {
287279 }
288280
289281 if ( $ due_now ) {
290- delete_transient ( 'doing_cron ' );
282+ delete_transient ( 'wp_cli_doing_cron ' );
291283 }
292284
293285 $ message = ( 1 === $ executed ) ? 'Executed a total of %d cron event. ' : 'Executed a total of %d cron events. ' ;
0 commit comments