Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6/src/wp-includes/wp-db.php

    r38133 r38442  
    735735     */
    736736    public function init_charset() {
     737        $charset = '';
     738        $collate = '';
     739
    737740        if ( function_exists('is_multisite') && is_multisite() ) {
    738741            $charset = 'utf8';
     
    809812            $collate = $this->collate;
    810813        if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) {
     814            $set_charset_succeeded = true;
     815
    811816            if ( $this->use_mysqli ) {
    812817                if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
    813                     mysqli_set_charset( $dbh, $charset );
     818                    $set_charset_succeeded = mysqli_set_charset( $dbh, $charset );
    814819                }
    815                 $query = $this->prepare( 'SET NAMES %s', $charset );
    816                 if ( ! empty( $collate ) )
    817                     $query .= $this->prepare( ' COLLATE %s', $collate );
    818                 mysqli_query( $dbh, $query );
     820
     821                if ( $set_charset_succeeded ) {
     822                    $query = $this->prepare( 'SET NAMES %s', $charset );
     823                    if ( ! empty( $collate ) )
     824                        $query .= $this->prepare( ' COLLATE %s', $collate );
     825                    mysqli_query( $dbh, $query );
     826                }
    819827            } else {
    820828                if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
    821                     mysql_set_charset( $charset, $dbh );
     829                    $set_charset_succeeded = mysql_set_charset( $charset, $dbh );
    822830                }
    823                 $query = $this->prepare( 'SET NAMES %s', $charset );
    824                 if ( ! empty( $collate ) )
    825                     $query .= $this->prepare( ' COLLATE %s', $collate );
    826                 mysql_query( $query, $dbh );
     831                if ( $set_charset_succeeded ) {
     832                    $query = $this->prepare( 'SET NAMES %s', $charset );
     833                    if ( ! empty( $collate ) )
     834                        $query .= $this->prepare( ' COLLATE %s', $collate );
     835                    mysql_query( $query, $dbh );
     836                }
    827837            }
    828838        }
Note: See TracChangeset for help on using the changeset viewer.