File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 16
16
},
17
17
"require-dev" : {
18
18
"wp-cli/entity-command" : " ^1.3 || ^2" ,
19
+ "wp-cli/eval-command" : " ^2.0" ,
19
20
"wp-cli/server-command" : " ^2.0" ,
20
21
"wp-cli/wp-cli-tests" : " ^3.1"
21
22
},
Original file line number Diff line number Diff line change @@ -360,3 +360,41 @@ Feature: Manage WP-Cron events and schedules
360
360
Then STDOUT should be CSV containing:
361
361
| hook | recurrence | args |
362
362
| wp_cli_test_args_event | Non -repeating | {"foo ":"banana ","bar ":"apple "} |
363
+
364
+ Scenario : Warn when an invalid cron event is detected
365
+ Given a WP install
366
+ And a update.php file:
367
+ """
368
+ <?php
369
+ $val = array(
370
+ 1647914509 => array(
371
+ 'postindexer_secondpass_cron' => array(
372
+ '40cd750bba9870f18aada2478b24840a' => array(
373
+ 'schedule' => '5mins',
374
+ 'args' => array(),
375
+ 'interval' => 100,
376
+ ),
377
+ ),
378
+ ),
379
+ 'wp_batch_split_terms' => array(
380
+ 1442323165 => array(
381
+ '40cd750bba9870f18aada2478b24840a' => array(
382
+ 'schedule' => false,
383
+ 'args' => array()
384
+ )
385
+ )
386
+ )
387
+ );
388
+ update_option( 'cron', $val );
389
+ """
390
+ And I run `wp eval-file update.php`
391
+
392
+ When I try `wp cron event list`
393
+ Then STDOUT should contain:
394
+ """
395
+ postindexer_secondpass_cron
396
+ """
397
+ And STDERR should contain:
398
+ """
399
+ Warning: Ignoring incorrectly registered cron event "wp_batch_split_terms".
400
+ """
Original file line number Diff line number Diff line change @@ -449,6 +449,13 @@ protected static function get_cron_events( $is_due_now = false ) {
449
449
}
450
450
451
451
foreach ( $ crons as $ time => $ hooks ) {
452
+
453
+ // Incorrectly registered cron events can produce a string key.
454
+ if ( is_string ( $ time ) ) {
455
+ WP_CLI ::warning ( sprintf ( 'Ignoring incorrectly registered cron event "%s". ' , $ time ) );
456
+ continue ;
457
+ }
458
+
452
459
foreach ( $ hooks as $ hook => $ hook_events ) {
453
460
foreach ( $ hook_events as $ sig => $ data ) {
454
461
You can’t perform that action at this time.
0 commit comments