diff --git a/features/core-update.feature b/features/core-update.feature index a52bcd3b..52d1c4a3 100644 --- a/features/core-update.feature +++ b/features/core-update.feature @@ -384,3 +384,38 @@ Feature: Update WordPress core """ Success: """ + + Scenario: No HTML output from async translation updates during core update + Given a WP install + And an empty cache + + # Using `try` in case there are checksum warnings. + When I try `wp core download --version=6.5 --locale=de_DE --force` + Then STDOUT should contain: + """ + Success: WordPress downloaded. + """ + + When I run `wp core version --extra` + Then STDOUT should contain: + """ + Package language: de_DE + """ + + When I run `wp core update --version=latest --force` + Then STDOUT should not contain: + """ +

+ """ + And STDOUT should not contain: + """ +

+ """ diff --git a/src/Core_Command.php b/src/Core_Command.php index b9bbb2b4..5e99e3ea 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1213,6 +1213,15 @@ public function update( $args, $assoc_args ) { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; + // Prevent async translation updates which output HTML. + add_action( + 'upgrader_process_complete', + function () { + remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); + }, + 1 + ); + if ( $update->version ) { WP_CLI::log( "Updating to version {$update->version} ({$update->locale})..." ); } else {