#11100 closed defect (bug) (fixed)
delete_post_meta_by_key() is currently broken
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9 |
| Component: | Database | Version: | 2.9 |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
$wpdb->prepare() quotes strings and therefore results in a broken query:
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN(%s)", implode( ',', $postmetaids) ) );
It results in something like this:
DELETE FROM wp_postmeta WHERE meta_id IN('883,1062,1063,1064,1066,1067,969')
There are likely other places where this is also an issue.
Attachments (1)
Change History (5)
Viper007Bond — 4 years ago
comment:1
Viper007Bond — 4 years ago
Props to DD32 by the way for pointing out to me what was going wrong.
- Owner changed from ryan to westi
- Status changed from new to accepted
I have added some testcases to wordpress-tests to catch this error.
I would prefer to keep the call to prepare here for consistency sake.
Going to commit an alternative fix which works for my local tests please re-open if there are still issues.
- Resolution set to fixed
- Status changed from accepted to closed
- Milestone changed from Unassigned to 2.9
- Version set to 2.9
Note: See
TracTickets for help on using
tickets.

Don't use prepare()