diff --git src/wp-includes/wp-db.php src/wp-includes/wp-db.php
index 89af746..d2aa5d1 100644
|
|
class wpdb { |
1252 | 1252 | $query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s |
1253 | 1253 | $query = preg_replace( '/%(?:%|$|([^dsF]))/', '%%\\1', $query ); // escape any unescaped percents |
1254 | 1254 | array_walk( $args, array( $this, 'escape_by_ref' ) ); |
| 1255 | |
| 1256 | /** |
| 1257 | * Patch to find number of convertible patterns in the query and match it to the arguments count |
| 1258 | * Throw a notice if there is a mismatch in the number of covertible patterns to the argument count passed in |
| 1259 | * I recommend exception over notice but keeping backward compatibility in mind, i have used notice. |
| 1260 | */ |
| 1261 | |
| 1262 | preg_match_all('/%(%|s|d|F)/', $query, $patterns, PREG_SET_ORDER, 0); // search for %% %s %d %F in the string |
| 1263 | $convertible_pattern_count = 0; |
| 1264 | |
| 1265 | foreach ( $patterns as $pattern ) { |
| 1266 | if (strcmp($pattern[0][1], "%")) { // as % is a escape pattern, ignore %% form the list of convertible pattern |
| 1267 | $convertible_pattern_count++; |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | if ( count( $args ) != $convertible_pattern_count ) { |
| 1272 | _doing_it_wrong( |
| 1273 | 'wpdb::prepare', |
| 1274 | sprintf('Number of argument passed is incorrect. Requires %d arguments, but %d arguments is passed', $convertible_pattern_count, count($args)), |
| 1275 | '4.8.2' //version needs to be updated accordingly |
| 1276 | ); |
| 1277 | } |
| 1278 | |
1255 | 1279 | return @vsprintf( $query, $args ); |
1256 | 1280 | } |
1257 | 1281 | |