Ticket #32029: 32029.diff
File 32029.diff, 2.4 KB (added by , 10 years ago) |
---|
-
src/wp-includes/wp-db.php
2399 2399 return true; 2400 2400 } 2401 2401 2402 // We don't need to check the collation for queries that don't read data. 2403 $query = ltrim( $query, "\r\n\t (" ); 2404 if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN)\s/i', $query ) ) { 2405 return true; 2406 } 2407 2402 2408 $table = $this->get_table_from_query( $query ); 2403 2409 if ( ! $table ) { 2404 2410 return false; … … 2405 2411 } 2406 2412 2407 2413 $this->checking_collation = true; 2408 $ this->get_table_charset( $table );2414 $collation = $this->get_table_charset( $table ); 2409 2415 $this->checking_collation = false; 2410 2416 2417 // Tables with no collation, or latin1 only, don't need extra checking. 2418 if ( false === $collation || 'latin1' === $collation ) { 2419 return true; 2420 } 2421 2411 2422 $table = strtolower( $table ); 2412 2423 if ( empty( $this->col_meta[ $table ] ) ) { 2413 2424 return false; 2414 2425 } 2415 2426 2427 // If any of the columns don't have one of these collations, it needs more sanity checking. 2416 2428 foreach( $this->col_meta[ $table ] as $col ) { 2417 2429 if ( empty( $col->Collation ) ) { 2418 2430 continue; -
tests/phpunit/tests/db/charset.php
505 505 $value[0] = "CREATE TABLE $this_table_name {$value[0]}"; 506 506 $value[2] = "SELECT * FROM $this_table_name"; 507 507 $value[3] = "DROP TABLE IF EXISTS $this_table_name"; 508 $value[4] = array( 509 "SHOW FULL TABLES LIKE $this_table_name", 510 "DESCRIBE $this_table_name", 511 "DESC $this_table_name", 512 "EXPLAIN SELECT * FROM $this_table_name", 513 ); 508 514 } 509 515 unset( $value ); 510 516 … … 516 522 * @dataProvider data_table_collation_check 517 523 * @ticket 21212 518 524 */ 519 function test_table_collation_check( $create, $expected, $query, $drop ) {525 function test_table_collation_check( $create, $expected, $query, $drop, $always_true ) { 520 526 self::$_wpdb->query( $drop ); 521 527 522 528 self::$_wpdb->query( $create ); … … 524 530 $return = self::$_wpdb->check_safe_collation( $query ); 525 531 $this->assertEquals( $expected, $return ); 526 532 533 foreach( $always_true as $true_query ) { 534 $return = self::$_wpdb->check_safe_collation( $true_query ); 535 $this->assertTrue( $return ); 536 } 537 527 538 self::$_wpdb->query( $drop ); 528 539 } 529 540 }