diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php
index 391cfa4..271bb7e 100644
|
a
|
b
|
class wpdb { |
| 1000 | 1000 | $query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting |
| 1001 | 1001 | $query = preg_replace( '|(?<!%)%f|' , '%F', $query ); // Force floats to be locale unaware |
| 1002 | 1002 | $query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s |
| | 1003 | |
| | 1004 | // START replace NULLs |
| | 1005 | preg_match_all( |
| | 1006 | '#\'?(?:[^%]|^)%(?:(\d+)\$)?[dfs]\'?#', |
| | 1007 | $query, |
| | 1008 | $positions, |
| | 1009 | PREG_OFFSET_CAPTURE |
| | 1010 | ); |
| | 1011 | if ( ! empty( $positions ) ) { |
| | 1012 | $init_count = count( $args ); |
| | 1013 | $args = array_values( $args ); |
| | 1014 | $index = 0; |
| | 1015 | $str_offset = 0; |
| | 1016 | $max_index = 0; |
| | 1017 | foreach ( $positions[0] as $ref => $pattern ) { |
| | 1018 | $loc_index = 0; |
| | 1019 | if ( ! empty( $positions[1][$ref] ) ) { |
| | 1020 | $loc_index = ( (int)$positions[1][$ref][0] ) - 1; |
| | 1021 | } else { |
| | 1022 | $loc_index = $index++; |
| | 1023 | } |
| | 1024 | if ( $loc_index > $max_index ) { |
| | 1025 | $max_index = $loc_index; |
| | 1026 | } |
| | 1027 | if ( ! isset( $args[$loc_index] ) ) { |
| | 1028 | unset( $args[$loc_index] ); // NULL is not set, but present |
| | 1029 | $format_length = strlen( $pattern[0] ); |
| | 1030 | $query = substr( |
| | 1031 | $query, |
| | 1032 | 0, |
| | 1033 | $pattern[1] + $str_offset |
| | 1034 | ) . ' NULL ' . |
| | 1035 | substr( |
| | 1036 | $query, |
| | 1037 | $pattern[1] + $format_length + $str_offset |
| | 1038 | ); |
| | 1039 | if ( $format_length != 6 ) { |
| | 1040 | $str_offset += 6 - $format_length; |
| | 1041 | } |
| | 1042 | } |
| | 1043 | } |
| | 1044 | if ( ++$max_index > $init_count ) { |
| | 1045 | return; // too few arguments provided |
| | 1046 | } |
| | 1047 | $args = array_values( $args ); |
| | 1048 | } |
| | 1049 | // END replace NULLs |
| | 1050 | |
| 1003 | 1051 | array_walk( $args, array( $this, 'escape_by_ref' ) ); |
| 1004 | 1052 | return @vsprintf( $query, $args ); |
| 1005 | 1053 | } |