Don't suppress error messages in database function calls.

Fixes #21870.

Built from https://develop.svn.wordpress.org/trunk@35860


git-svn-id: http://core.svn.wordpress.org/trunk@35824 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Eric Lewis 2015-12-11 03:40:26 +00:00
parent 49e2977b7e
commit b07bb412ee
2 changed files with 17 additions and 25 deletions

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-35859';
$wp_version = '4.5-alpha-35860';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -1044,9 +1044,9 @@ class wpdb {
$dbh = $this->dbh;
if ( $this->use_mysqli ) {
$success = @mysqli_select_db( $dbh, $db );
$success = mysqli_select_db( $dbh, $db );
} else {
$success = @mysql_select_db( $db, $dbh );
$success = mysql_select_db( $db, $dbh );
}
if ( ! $success ) {
$this->ready = false;
@ -1484,11 +1484,7 @@ class wpdb {
}
}
if ( WP_DEBUG ) {
mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
} else {
@mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
}
mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
if ( $this->dbh->connect_errno ) {
$this->dbh = null;
@ -1514,11 +1510,7 @@ class wpdb {
}
}
} else {
if ( WP_DEBUG ) {
$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
} else {
$this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
}
$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
}
if ( ! $this->dbh && $allow_bail ) {
@ -1589,11 +1581,11 @@ class wpdb {
*/
public function check_connection( $allow_bail = true ) {
if ( $this->use_mysqli ) {
if ( @mysqli_ping( $this->dbh ) ) {
if ( ! empty( $this->dbh ) && mysqli_ping( $this->dbh ) ) {
return true;
}
} else {
if ( @mysql_ping( $this->dbh ) ) {
if ( ! empty( $this->dbh ) && mysql_ping( $this->dbh ) ) {
return true;
}
}
@ -1770,12 +1762,12 @@ class wpdb {
} else {
$num_rows = 0;
if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
while ( $row = @mysqli_fetch_object( $this->result ) ) {
while ( $row = mysqli_fetch_object( $this->result ) ) {
$this->last_result[$num_rows] = $row;
$num_rows++;
}
} elseif ( is_resource( $this->result ) ) {
while ( $row = @mysql_fetch_object( $this->result ) ) {
while ( $row = mysql_fetch_object( $this->result ) ) {
$this->last_result[$num_rows] = $row;
$num_rows++;
}
@ -1805,10 +1797,10 @@ class wpdb {
$this->timer_start();
}
if ( $this->use_mysqli ) {
$this->result = @mysqli_query( $this->dbh, $query );
} else {
$this->result = @mysql_query( $query, $this->dbh );
if ( ! empty( $this->dbh ) && $this->use_mysqli ) {
$this->result = mysqli_query( $this->dbh, $query );
} elseif ( ! empty( $this->dbh ) ) {
$this->result = mysql_query( $query, $this->dbh );
}
$this->num_queries++;
@ -3016,14 +3008,14 @@ class wpdb {
return;
if ( $this->use_mysqli ) {
$num_fields = @mysqli_num_fields( $this->result );
$num_fields = mysqli_num_fields( $this->result );
for ( $i = 0; $i < $num_fields; $i++ ) {
$this->col_info[ $i ] = @mysqli_fetch_field( $this->result );
$this->col_info[ $i ] = mysqli_fetch_field( $this->result );
}
} else {
$num_fields = @mysql_num_fields( $this->result );
$num_fields = mysql_num_fields( $this->result );
for ( $i = 0; $i < $num_fields; $i++ ) {
$this->col_info[ $i ] = @mysql_fetch_field( $this->result, $i );
$this->col_info[ $i ] = mysql_fetch_field( $this->result, $i );
}
}
}