diff --git a/wp-includes/version.php b/wp-includes/version.php index c19da62375..5a46ba01e4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38439'; +$wp_version = '4.7-alpha-38441'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 3c07900a72..02577b910d 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -811,22 +811,29 @@ class wpdb { if ( ! isset( $collate ) ) $collate = $this->collate; if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) { + $set_charset_succeeded = true; + if ( $this->use_mysqli ) { if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) { - mysqli_set_charset( $dbh, $charset ); + $set_charset_succeeded = mysqli_set_charset( $dbh, $charset ); + } + + if ( $set_charset_succeeded ) { + $query = $this->prepare( 'SET NAMES %s', $charset ); + if ( ! empty( $collate ) ) + $query .= $this->prepare( ' COLLATE %s', $collate ); + mysqli_query( $dbh, $query ); } - $query = $this->prepare( 'SET NAMES %s', $charset ); - if ( ! empty( $collate ) ) - $query .= $this->prepare( ' COLLATE %s', $collate ); - mysqli_query( $dbh, $query ); } else { if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset' ) ) { - mysql_set_charset( $charset, $dbh ); + $set_charset_succeeded = mysql_set_charset( $charset, $dbh ); + } + if ( $set_charset_succeeded ) { + $query = $this->prepare( 'SET NAMES %s', $charset ); + if ( ! empty( $collate ) ) + $query .= $this->prepare( ' COLLATE %s', $collate ); + mysql_query( $query, $dbh ); } - $query = $this->prepare( 'SET NAMES %s', $charset ); - if ( ! empty( $collate ) ) - $query .= $this->prepare( ' COLLATE %s', $collate ); - mysql_query( $query, $dbh ); } } }