Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"require-dev": {
"wp-cli/entity-command": "^1.3 || ^2",
"wp-cli/eval-command": "^2.0",
"wp-cli/server-command": "^2.0",
"wp-cli/wp-cli-tests": "^3.1"
},
Expand Down
38 changes: 38 additions & 0 deletions features/cron.feature
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,41 @@ Feature: Manage WP-Cron events and schedules
Then STDOUT should be CSV containing:
| hook | recurrence | args |
| wp_cli_test_args_event | Non-repeating | {"foo":"banana","bar":"apple"} |

Scenario: Warn when an invalid cron event is detected
Given a WP install
And a update.php file:
"""
<?php
$val = array(
1647914509 => array(
'postindexer_secondpass_cron' => array(
'40cd750bba9870f18aada2478b24840a' => array(
'schedule' => '5mins',
'args' => array(),
'interval' => 100,
),
),
),
'wp_batch_split_terms' => array(
1442323165 => array(
'40cd750bba9870f18aada2478b24840a' => array(
'schedule' => false,
'args' => array()
)
)
)
);
update_option( 'cron', $val );
"""
And I run `wp eval-file update.php`

When I try `wp cron event list`
Then STDOUT should contain:
"""
postindexer_secondpass_cron
"""
And STDERR should contain:
"""
Warning: Ignoring incorrectly registered cron event "wp_batch_split_terms".
"""
7 changes: 7 additions & 0 deletions src/Cron_Event_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ protected static function get_cron_events( $is_due_now = false ) {
}

foreach ( $crons as $time => $hooks ) {

// Incorrectly registered cron events can produce a string key.
if ( is_string( $time ) ) {
WP_CLI::warning( sprintf( 'Ignoring incorrectly registered cron event "%s".', $time ) );
continue;
}

foreach ( $hooks as $hook => $hook_events ) {
foreach ( $hook_events as $sig => $data ) {

Expand Down