Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#11100 closed defect (bug) (fixed)

delete_post_meta_by_key() is currently broken

Reported by: Viper007Bond Owned by: westi
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)

11100.patch (754 bytes) - added by Viper007Bond 4 years ago.
Don't use prepare()

Download all attachments as: .zip

Change History (5)

Don't use prepare()

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

(In [12156]) Fix delete_post_meta_by_key() so that you can delete postmeta items by key again. Fixes #11100.

  • Milestone changed from Unassigned to 2.9
  • Version set to 2.9
Note: See TracTickets for help on using tickets.