From 2b7ef51042b123ced3f22993945dfa19d0e883c4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 1 Nov 2025 19:59:13 +0000 Subject: [PATCH 1/4] Initial plan From 537e8499a52d562f121a3d24b2154ddf3263a89d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 1 Nov 2025 20:09:08 +0000 Subject: [PATCH 2/4] Add debug output for cron event arguments Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/cron-event.feature | 28 ++++++++++++++++++++++++++++ src/Cron_Event_Command.php | 3 +++ 2 files changed, 31 insertions(+) diff --git a/features/cron-event.feature b/features/cron-event.feature index 86356f20..949602e4 100644 --- a/features/cron-event.feature +++ b/features/cron-event.feature @@ -130,3 +130,31 @@ Feature: Manage WP Cron events """ LOG A SHUTDOWN FROM ERROR """ + + Scenario: Run cron event with arguments and debug output + When I run `wp cron event schedule wp_cli_test_event_with_args now --0=123 --1=test-value` + Then STDOUT should contain: + """ + Success: Scheduled event with hook 'wp_cli_test_event_with_args' + """ + + When I run `wp cron event run wp_cli_test_event_with_args --due-now --debug=cron` + Then STDOUT should contain: + """ + Executed the cron event 'wp_cli_test_event_with_args' + """ + And STDOUT should contain: + """ + Debug (cron): Arguments: ["123","test-value"] + """ + + When I run `wp cron event schedule wp_cli_test_event_no_args now` + And I run `wp cron event run wp_cli_test_event_no_args --due-now --debug=cron` + Then STDOUT should contain: + """ + Executed the cron event 'wp_cli_test_event_no_args' + """ + And STDOUT should not contain: + """ + Debug (cron): Arguments: + """ diff --git a/src/Cron_Event_Command.php b/src/Cron_Event_Command.php index e789267c..5035e02b 100644 --- a/src/Cron_Event_Command.php +++ b/src/Cron_Event_Command.php @@ -248,6 +248,9 @@ public function run( $args, $assoc_args ) { $total = round( microtime( true ) - $start, 3 ); ++$executed; WP_CLI::log( sprintf( "Executed the cron event '%s' in %ss.", $event->hook, $total ) ); + if ( ! empty( $event->args ) ) { + WP_CLI::debug( sprintf( "Arguments: %s", wp_json_encode( $event->args ) ), 'cron' ); + } } $message = ( 1 === $executed ) ? 'Executed a total of %d cron event.' : 'Executed a total of %d cron events.'; From 2077acdfccbf5c18172d3ca559669cc8ceac7dd6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 1 Nov 2025 20:25:40 +0000 Subject: [PATCH 3/4] Fix PHPCS error and correct test assertion format Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/cron-event.feature | 2 +- src/Cron_Event_Command.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/cron-event.feature b/features/cron-event.feature index 949602e4..98c164e5 100644 --- a/features/cron-event.feature +++ b/features/cron-event.feature @@ -145,7 +145,7 @@ Feature: Manage WP Cron events """ And STDOUT should contain: """ - Debug (cron): Arguments: ["123","test-value"] + Debug: Arguments: ["123","test-value"] """ When I run `wp cron event schedule wp_cli_test_event_no_args now` diff --git a/src/Cron_Event_Command.php b/src/Cron_Event_Command.php index 5035e02b..e3e74720 100644 --- a/src/Cron_Event_Command.php +++ b/src/Cron_Event_Command.php @@ -249,7 +249,7 @@ public function run( $args, $assoc_args ) { ++$executed; WP_CLI::log( sprintf( "Executed the cron event '%s' in %ss.", $event->hook, $total ) ); if ( ! empty( $event->args ) ) { - WP_CLI::debug( sprintf( "Arguments: %s", wp_json_encode( $event->args ) ), 'cron' ); + WP_CLI::debug( sprintf( 'Arguments: %s', wp_json_encode( $event->args ) ), 'cron' ); } } From f0d87057f89ad632f56d1ab581ac56f5cfcbcf65 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 1 Nov 2025 21:05:53 +0000 Subject: [PATCH 4/4] Fix test to check STDERR for debug output Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/cron-event.feature | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/features/cron-event.feature b/features/cron-event.feature index 98c164e5..2512d887 100644 --- a/features/cron-event.feature +++ b/features/cron-event.feature @@ -138,23 +138,23 @@ Feature: Manage WP Cron events Success: Scheduled event with hook 'wp_cli_test_event_with_args' """ - When I run `wp cron event run wp_cli_test_event_with_args --due-now --debug=cron` + When I try `wp cron event run wp_cli_test_event_with_args --due-now --debug=cron` Then STDOUT should contain: """ Executed the cron event 'wp_cli_test_event_with_args' """ - And STDOUT should contain: + And STDERR should contain: """ Debug: Arguments: ["123","test-value"] """ When I run `wp cron event schedule wp_cli_test_event_no_args now` - And I run `wp cron event run wp_cli_test_event_no_args --due-now --debug=cron` + And I try `wp cron event run wp_cli_test_event_no_args --due-now --debug=cron` Then STDOUT should contain: """ Executed the cron event 'wp_cli_test_event_no_args' """ - And STDOUT should not contain: + And STDERR should not contain: """ - Debug (cron): Arguments: + Debug: Arguments: """