Changeset 37320
- Timestamp:
- 04/28/2016 01:38:31 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/wp-db.php
r37292 r37320 781 781 if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) { 782 782 mysqli_set_charset( $dbh, $charset ); 783 } else {784 $query = $this->prepare( 'SET NAMES %s', $charset );785 if ( ! empty( $collate ) )786 $query .= $this->prepare( ' COLLATE %s', $collate );787 mysqli_query( $dbh, $query );788 783 } 784 $query = $this->prepare( 'SET NAMES %s', $charset ); 785 if ( ! empty( $collate ) ) 786 $query .= $this->prepare( ' COLLATE %s', $collate ); 787 mysqli_query( $dbh, $query ); 789 788 } else { 790 789 if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset' ) ) { 791 790 mysql_set_charset( $charset, $dbh ); 792 } else {793 $query = $this->prepare( 'SET NAMES %s', $charset );794 if ( ! empty( $collate ) )795 $query .= $this->prepare( ' COLLATE %s', $collate );796 mysql_query( $query, $dbh );797 791 } 792 $query = $this->prepare( 'SET NAMES %s', $charset ); 793 if ( ! empty( $collate ) ) 794 $query .= $this->prepare( ' COLLATE %s', $collate ); 795 mysql_query( $query, $dbh ); 798 796 } 799 797 } -
trunk/tests/phpunit/tests/db/charset.php
r36116 r37320 17 17 public static function setUpBeforeClass() { 18 18 require_once( dirname( dirname( __FILE__ ) ) . '/db.php' ); 19 19 20 20 self::$_wpdb = new wpdb_exposed_methods_for_testing(); 21 21 } … … 892 892 $this->assertEquals( $safe_query, $stripped_query ); 893 893 } 894 895 /** 896 * @ticket 36649 897 */ 898 function test_set_charset_changes_the_connection_collation() { 899 self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8', 'utf8_general_ci' ); 900 $results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" ); 901 $this->assertEquals( 'utf8_general_ci', $results[0]->Value ); 902 903 self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8mb4', 'utf8mb4_unicode_ci' ); 904 $results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" ); 905 $this->assertEquals( 'utf8mb4_unicode_ci', $results[0]->Value ); 906 907 self::$_wpdb->set_charset( self::$_wpdb->dbh ); 908 } 894 909 }
Note: See TracChangeset
for help on using the changeset viewer.