From 5463bd2d3804b1db5bca6884b7a3d76e4eebdd33 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 09:22:34 +0000 Subject: [PATCH 1/5] Initial plan From 90eefd17885864974f6f91c1abec22467b178a82 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 09:30:00 +0000 Subject: [PATCH 2/5] Add support for displaying unexpected plugin output during activation Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/plugin-activate.feature | 23 +++++++++++++++++++++++ src/Plugin_Command.php | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/features/plugin-activate.feature b/features/plugin-activate.feature index 9c474244..a479e801 100644 --- a/features/plugin-activate.feature +++ b/features/plugin-activate.feature @@ -154,3 +154,26 @@ Feature: Activate WordPress plugins Success: """ And the return code should be 0 + + Scenario: Activating a plugin that generates unexpected output shows the output in debug mode + Given a wp-content/plugins/output-plugin.php file: + """ + get_error_code() ) { + $output = $result->get_error_data(); + if ( ! empty( $output ) ) { + WP_CLI::debug( "Unexpected output: {$output}", 'plugin' ); + } + } ++$errors; } else { $this->active_output( $plugin->name, $plugin->file, $network_wide, 'activate' ); From b082258754791c6a367f91a34b8f903c2b4b1c51 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 6 Nov 2025 12:15:21 +0100 Subject: [PATCH 3/5] Add casting --- src/Plugin_Command.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 9ae9ba34..71cc3611 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -404,6 +404,9 @@ public function activate( $args, $assoc_args = [] ) { // If the error is due to unexpected output, display it for debugging if ( 'unexpected_output' === $result->get_error_code() ) { + /** + * @var string $output + */ $output = $result->get_error_data(); if ( ! empty( $output ) ) { WP_CLI::debug( "Unexpected output: {$output}", 'plugin' ); From 32d7af060d250c1e441b1071120d040da8284ddd Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 6 Nov 2025 12:15:37 +0100 Subject: [PATCH 4/5] Remove blanks --- src/Plugin_Command.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 71cc3611..af7e47b4 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -401,7 +401,6 @@ public function activate( $args, $assoc_args = [] ) { $message = wp_strip_all_tags( $message ); $message = str_replace( 'Error: ', '', $message ); WP_CLI::warning( "Failed to activate plugin. {$message}" ); - // If the error is due to unexpected output, display it for debugging if ( 'unexpected_output' === $result->get_error_code() ) { /** From fd3856fb225d6297abde4359d08312248c520e0d Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 6 Nov 2025 13:00:38 +0100 Subject: [PATCH 5/5] Remove errant space --- src/Plugin_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index af7e47b4..918f8573 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -405,7 +405,7 @@ public function activate( $args, $assoc_args = [] ) { if ( 'unexpected_output' === $result->get_error_code() ) { /** * @var string $output - */ + */ $output = $result->get_error_data(); if ( ! empty( $output ) ) { WP_CLI::debug( "Unexpected output: {$output}", 'plugin' );