Make WordPress Core

Ticket #37689: 37689.diff

File 37689.diff, 1.6 KB (added by pento, 9 years ago)
  • src/wp-includes/wp-db.php

     
    808808                if ( ! isset( $collate ) )
    809809                        $collate = $this->collate;
    810810                if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) {
     811                        $set_charset_succeeded = true;
     812
    811813                        if ( $this->use_mysqli ) {
    812814                                if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
    813                                         mysqli_set_charset( $dbh, $charset );
     815                                        $set_charset_succeeded = mysqli_set_charset( $dbh, $charset );
     816                                }
     817
     818                                if ( $set_charset_succeeded ) {
     819                                        $query = $this->prepare( 'SET NAMES %s', $charset );
     820                                        if ( ! empty( $collate ) )
     821                                                $query .= $this->prepare( ' COLLATE %s', $collate );
     822                                        mysqli_query( $dbh, $query );
    814823                                }
    815                                 $query = $this->prepare( 'SET NAMES %s', $charset );
    816                                 if ( ! empty( $collate ) )
    817                                         $query .= $this->prepare( ' COLLATE %s', $collate );
    818                                 mysqli_query( $dbh, $query );
    819824                        } else {
    820825                                if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
    821                                         mysql_set_charset( $charset, $dbh );
     826                                        $set_charset_succeeded = mysql_set_charset( $charset, $dbh );
     827                                }
     828                                if ( $set_charset_succeeded ) {
     829                                        $query = $this->prepare( 'SET NAMES %s', $charset );
     830                                        if ( ! empty( $collate ) )
     831                                                $query .= $this->prepare( ' COLLATE %s', $collate );
     832                                        mysql_query( $query, $dbh );
    822833                                }
    823                                 $query = $this->prepare( 'SET NAMES %s', $charset );
    824                                 if ( ! empty( $collate ) )
    825                                         $query .= $this->prepare( ' COLLATE %s', $collate );
    826                                 mysql_query( $query, $dbh );
    827834                        }
    828835                }
    829836        }