Changeset 32240
- Timestamp:
- 04/21/2015 07:00:52 AM (9 years ago)
- Location:
- branches/3.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.8/src/wp-includes/wp-db.php
r32186 r32240 1959 1959 return true; 1960 1960 } 1961 1962 // We don't need to check the collation for queries that don't read data. 1963 $query = ltrim( $query, "\r\n\t (" ); 1964 if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN)\s/i', $query ) ) { 1965 return true; 1966 } 1967 1968 // All-ASCII queries don't need extra checking. 1969 if ( $this->check_ascii( $query ) ) { 1970 return true; 1971 } 1972 1961 1973 $table = $this->get_table_from_query( $query ); 1962 1974 if ( ! $table ) { … … 1965 1977 1966 1978 $this->checking_collation = true; 1967 $ this->get_table_charset( $table );1979 $collation = $this->get_table_charset( $table ); 1968 1980 $this->checking_collation = false; 1981 1982 // Tables with no collation, or latin1 only, don't need extra checking. 1983 if ( false === $collation || 'latin1' === $collation ) { 1984 return true; 1985 } 1969 1986 1970 1987 $table = strtolower( $table ); … … 1973 1990 } 1974 1991 1992 // If any of the columns don't have one of these collations, it needs more sanity checking. 1975 1993 foreach( $this->col_meta[ $table ] as $col ) { 1976 1994 if ( empty( $col->Collation ) ) { … … 2000 2018 * remove invalid characters, a {@see WP_Error} object is returned. 2001 2019 */ 2020 // If any of the columns don't have one of these collations, it needs more sanity checking. 2002 2021 protected function strip_invalid_text( $data ) { 2003 2022 // Some multibyte character sets that we can check in PHP. -
branches/3.8/tests/phpunit/tests/db/charset.php
r32238 r32240 500 500 501 501 $value[0] = "CREATE TABLE $this_table_name {$value[0]}"; 502 $value[2] = "SELECT * FROM $this_table_name ";502 $value[2] = "SELECT * FROM $this_table_name WHERE a='\xf0\x9f\x98\x88'"; 503 503 $value[3] = "DROP TABLE IF EXISTS $this_table_name"; 504 $value[4] = array( 505 "SELECT * FROM $this_table_name WHERE a='foo'", 506 "SHOW FULL TABLES LIKE $this_table_name", 507 "DESCRIBE $this_table_name", 508 "DESC $this_table_name", 509 "EXPLAIN SELECT * FROM $this_table_name", 510 ); 504 511 } 505 512 unset( $value ); … … 513 520 * @ticket 21212 514 521 */ 515 function test_table_collation_check( $create, $expected, $query, $drop ) {522 function test_table_collation_check( $create, $expected, $query, $drop, $always_true ) { 516 523 self::$_wpdb->query( $drop ); 517 524 … … 521 528 $this->assertEquals( $expected, $return ); 522 529 530 foreach( $always_true as $true_query ) { 531 $return = self::$_wpdb->check_safe_collation( $true_query ); 532 $this->assertTrue( $return ); 533 } 534 523 535 self::$_wpdb->query( $drop ); 524 536 }
Note: See TracChangeset
for help on using the changeset viewer.