#41926 closed defect (bug) (duplicate)
wpdb->prepare() method inhibits argument numbering
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | 4.8.2 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
Since 4.8.2 an additional line was added to escape any unescaped percents:
$query = preg_replace( '/%(?:%|$|([^dsF]))/', '%%\\1', $query ); // escape any unescaped percents
this however prohibits the use of numbered arguments like in this query from Yoast SEO plugin:
$query = $wpdb->prepare( 'SELECT COUNT( id ) AS incoming, target_post_id AS post_id FROM %2$s WHERE target_post_id IN( %3$s ) GROUP BY target_post_id', $this->get_table_name(), $storage->get_table_name(), implode( ', ', $post_ids ) );
Change History (4)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Yoast SEO is actually doing it wrong since numbered arguments are not supported by
wpdb::prepare(). There's a pending PR to fix this.Closing as a duplicate #41925 which requests to add support for numbered arguments.