Opened 4 years ago

Closed 4 years ago

#9009 closed defect (bug) (fixed)

delete_post_meta_by_key() fix

Reported by: Denis-de-Bernardy Owned by: anonymous
Priority: normal Milestone: 2.8
Component: Optimization Version: 2.7
Severity: major Keywords: has-patch tested commit
Cc:

Description

patch for the todo item is attached

Attachments (3)

9009-enhanced.diff (924 bytes) - added by Denis-de-Bernardy 4 years ago.
9009-enhanced-2.diff (1.4 KB) - added by Denis-de-Bernardy 4 years ago.
9009.diff (800 bytes) - added by Denis-de-Bernardy 4 years ago.
refreshed against 11255

Download all attachments as: .zip

Change History (12)

  • Keywords dev-feedback added

The second patch is a suggested enhancement. It replaces the = operator with a LIKE operator, allowing to mass-delete post meta, like:

delete_post_meta_by_key('_plugin_cache_%')

I needed this a couple of time in my own plugins and ended up using SQL to achieve it. Having it in the wp core would be a plus.

Second enhanced version lets one use LIKE, NOT LIKE, REGEXP AND NOT REGEXP, as necessary.

  • Keywords tested added; dev-feedback removed

enhanced and enhanced2 diffs are bad ideas on second though. the first patch is the correct one to use.

  • Keywords commit added
  • Severity changed from normal to major

refreshed against 11255

  • Component changed from General to Optimization
  • Summary changed from delete_post_meta_by_key() fix + enhancement to delete_post_meta_by_key() fix

comment:9   ryan4 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11305]) Clear cache after deleting meta. Props Denis-de-Bernardy. fixes #9009

Note: See TracTickets for help on using tickets.