diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php
index 391cfa4..9422835 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 | $values = array_values( $args ); |
| | 1013 | $index = 0; |
| | 1014 | $str_offset = 0; |
| | 1015 | $max_index = 0; |
| | 1016 | foreach ( $positions[0] as $ref => $pattern ) { |
| | 1017 | $loc_index = 0; |
| | 1018 | if ( ! empty( $positions[1][$ref] ) ) { |
| | 1019 | $loc_index = ( (int)$positions[1][$ref][0] ) - 1; |
| | 1020 | } else { |
| | 1021 | $loc_index = $index++; |
| | 1022 | } |
| | 1023 | if ( $loc_index > $max_index ) { |
| | 1024 | $max_index = $loc_index; |
| | 1025 | } |
| | 1026 | if ( ! isset( $values[$loc_index] ) ) { |
| | 1027 | unset( $values[$loc_index] ); // NULL is not set, but present |
| | 1028 | $format_length = strlen( $pattern[0] ); |
| | 1029 | $query = substr( |
| | 1030 | $query, |
| | 1031 | 0, |
| | 1032 | $pattern[1] + $str_offset |
| | 1033 | ) . ' NULL ' . |
| | 1034 | substr( |
| | 1035 | $query, |
| | 1036 | $pattern[1] + $format_length + $str_offset |
| | 1037 | ); |
| | 1038 | if ( $format_length != 6 ) { |
| | 1039 | $str_offset += 6 - $format_length; |
| | 1040 | } |
| | 1041 | } |
| | 1042 | } |
| | 1043 | if ( ++$max_index > count( $args ) ) { |
| | 1044 | return; // too few arguments provided |
| | 1045 | } |
| | 1046 | $args = array_values( $values ); |
| | 1047 | } |
| | 1048 | // END replace NULLs |
| | 1049 | |
| 1003 | 1050 | array_walk( $args, array( $this, 'escape_by_ref' ) ); |
| 1004 | 1051 | return @vsprintf( $query, $args ); |
| 1005 | 1052 | } |