diff --git a/features/db.feature b/features/db.feature index 5c33e6d000..ae97e59333 100644 --- a/features/db.feature +++ b/features/db.feature @@ -9,7 +9,7 @@ Feature: Perform database operations Then STDOUT should be empty And STDERR should be: """ - Error: Can’t select database + Error: Can’t select database. We were able to connect to the database server (which means your username and password is okay) but not able to select the `wp_cli_test` database. """ When I run `wp db create` diff --git a/features/framework.feature b/features/framework.feature index 83732a03ea..3e1751e99f 100644 --- a/features/framework.feature +++ b/features/framework.feature @@ -195,11 +195,11 @@ Feature: Load WP-CLI When I try `wp --require=invalid-host.php option get home` Then STDERR should contain: """ - Error: Error establishing a database connection + Error: Error establishing a database connection. """ When I try `wp --require=invalid-host.php --require=wp-debug.php option get home` Then STDERR should contain: """ - Error: Error establishing a database connection + Error: Error establishing a database connection. """ diff --git a/php/utils-wp.php b/php/utils-wp.php index 416fa28510..2b5ffbd388 100644 --- a/php/utils-wp.php +++ b/php/utils-wp.php @@ -54,11 +54,20 @@ function wp_die_handler( $message ) { $message = $message->get_error_message(); } - $message = trim( $message ); - if ( preg_match( '|^\
(.+?)
|', $original_message, $matches ) ) { + $message .= ' ' . $matches[1]; } + $search_replace = array( + '' => '`',
+ '' => '`',
+ );
+ $message = str_replace( array_keys( $search_replace ), array_values( $search_replace ), $message );
+ $message = strip_tags( $message );
$message = html_entity_decode( $message, ENT_COMPAT, 'UTF-8' );
\WP_CLI::error( $message );