Changeset 30375
- Timestamp:
- 11/18/2014 03:37:23 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/wp-db.php
r30366 r30375 2212 2212 2213 2213 foreach ( $columns as $column ) { 2214 if ( $column->Collation) {2214 if ( ! empty( $column->Collation ) ) { 2215 2215 list( $charset ) = explode( '_', $column->Collation ); 2216 2216 $charsets[ strtolower( $charset ) ] = true; … … 2238 2238 } elseif ( 0 === $count ) { 2239 2239 // No charsets, assume this table can store whatever. 2240 $charset = 'latin1';2240 $charset = false; 2241 2241 } else { 2242 2242 // More than one charset. Remove latin1 if present and recalculate. … … 2292 2292 } 2293 2293 2294 // Skip this entirely if this isn't a MySQL database. 2295 if ( false === $this->is_mysql ) { 2296 return false; 2297 } 2298 2294 2299 if ( empty( $this->table_charset[ $table ] ) ) { 2295 2300 // This primes column information for us. … … 2379 2384 $charset = $value['charset']; 2380 2385 2381 // latin1will happily store anything.2382 if ( 'latin1' === $charset ) {2386 // Column isn't a string, or is latin1, which will will happily store anything. 2387 if ( false === $charset || 'latin1' === $charset ) { 2383 2388 continue; 2384 2389 } 2385 2390 2386 // Column or value isn't a string. 2387 if ( false === $charset || ! is_string( $value['value'] ) ) { 2391 if ( ! is_string( $value['value'] ) ) { 2388 2392 continue; 2389 2393 } -
trunk/tests/phpunit/tests/db/charset.php
r30345 r30375 232 232 array( 233 233 'definition' => '( a INT, b FLOAT )', 234 'table_expected' => 'latin1',234 'table_expected' => false, 235 235 'column_expected' => array( 'a' => false, 'b' => false ) 236 236 ), … … 345 345 346 346 self::$_wpdb->query( $drop ); 347 } 348 349 /** 350 * @dataProvider data_test_get_column_charset 351 * @ticket 21212 352 */ 353 function test_get_column_charset_non_mysql( $drop, $create, $table, $columns ) { 354 self::$_wpdb->query( $drop ); 355 356 if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { 357 $this->markTestSkipped( "This version of MySQL doesn't support utf8mb4." ); 358 return; 359 } 360 361 self::$_wpdb->is_mysql = false; 362 363 self::$_wpdb->query( $create ); 364 365 $columns = array_keys( $columns ); 366 foreach ( $columns as $column => $charset ) { 367 $this->assertEquals( false, self::$_wpdb->get_col_charset( $table, $column ) ); 368 } 369 370 self::$_wpdb->query( $drop ); 371 372 self::$_wpdb->is_mysql = true; 347 373 } 348 374
Note: See TracChangeset
for help on using the changeset viewer.