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
2 changes: 1 addition & 1 deletion features/db.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions features/framework.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
15 changes: 12 additions & 3 deletions php/utils-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,20 @@ function wp_die_handler( $message ) {
$message = $message->get_error_message();
}

$message = trim( $message );
if ( preg_match( '|^\<h1>(.+?)</h1>|', $message, $matches ) ) {
$message = $matches[1];
$original_message = $message = trim( $message );
if ( preg_match( '|^\<h1>(.+?)</h1>|', $original_message, $matches ) ) {
$message = $matches[1] . '.';
}
if ( preg_match( '|\<p>(.+?)</p>|', $original_message, $matches ) ) {
$message .= ' ' . $matches[1];
}

$search_replace = array(
'<code>' => '`',
'</code>' => '`',
);
$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 );
Expand Down