Changeset 41499
- Timestamp:
- 09/19/2017 06:12:56 PM (9 years ago)
- Location:
- branches/4.6
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
src/wp-includes/wp-db.php (modified) (2 diffs)
-
tests/phpunit/tests/db.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/4.6
-
branches/4.6/src/wp-includes/wp-db.php
r41486 r41499 1315 1315 $query = preg_replace( '|(?<!%)%f|' , '%F', $query ); // Force floats to be locale unaware 1316 1316 $query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s 1317 $query = preg_replace( '/%(?:%|$|([^dsF]))/', '%%\\1', $query ); // escape any unescaped percents 1317 1318 array_walk( $args, array( $this, 'escape_by_ref' ) ); 1318 1319 return @vsprintf( $query, $args ); … … 2896 2897 2897 2898 if ( is_array( $value['length'] ) ) { 2898 $queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), %.0f ) USING $connection_charset )", $value['value'], $value['length']['length'] ); 2899 $length = sprintf( '%.0f', $value['length']['length'] ); 2900 $queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), $length ) USING $connection_charset )", $value['value'] ); 2899 2901 } else if ( 'binary' !== $charset ) { 2900 2902 // If we don't have a length, there's no need to convert binary - it will always return the same result. -
branches/4.6/tests/phpunit/tests/db.php
r41473 r41499 268 268 } 269 269 270 270 271 /** 271 272 * Test that SQL modes are set correctly … … 1089 1090 $this->assertSame( 'utf8_general_ci', $result['collate'] ); 1090 1091 } 1092 1093 /** 1094 * 1095 */ 1096 function test_prepare_with_unescaped_percents() { 1097 global $wpdb; 1098 1099 $sql = $wpdb->prepare( '%d %1$d %%% %', 1 ); 1100 $this->assertEquals( '1 %1$d %% %', $sql ); 1101 } 1091 1102 }
Note: See TracChangeset
for help on using the changeset viewer.