Database: If both `WP_DEBUG` and `WP_DEBUG_DISPLAY` are true, display a more specific error message in `wpdb::bail()`.
Props sivel, Mte90, SergeyBiryukov. Fixes #13657. Built from https://develop.svn.wordpress.org/trunk@42716 git-svn-id: http://core.svn.wordpress.org/trunk@42544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e17e29d4ea
commit
e50b9c943f
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-42715';
|
||||
$wp_version = '5.0-alpha-42716';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -3316,15 +3316,37 @@ class wpdb {
|
|||
* @return false|void
|
||||
*/
|
||||
public function bail( $message, $error_code = '500' ) {
|
||||
if ( ! $this->show_errors ) {
|
||||
if ( $this->show_errors ) {
|
||||
$error = '';
|
||||
|
||||
if ( $this->use_mysqli ) {
|
||||
if ( $this->dbh instanceof mysqli ) {
|
||||
$error = mysqli_error( $this->dbh );
|
||||
} elseif ( mysqli_connect_errno() ) {
|
||||
$error = mysqli_connect_error();
|
||||
}
|
||||
} else {
|
||||
if ( is_resource( $this->dbh ) ) {
|
||||
$error = mysql_error( $this->dbh );
|
||||
} else {
|
||||
$error = mysql_error();
|
||||
}
|
||||
}
|
||||
|
||||
if ( $error ) {
|
||||
$message = '<p><code>' . $error . "</code></p>\n" . $message;
|
||||
}
|
||||
|
||||
wp_die( $message );
|
||||
} else {
|
||||
if ( class_exists( 'WP_Error', false ) ) {
|
||||
$this->error = new WP_Error( $error_code, $message );
|
||||
} else {
|
||||
$this->error = $message;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
wp_die( $message );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue