WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#11125 closed defect (bug) (fixed)

added_{$meta_type}_meta, and update_{$meta_type}_meta actions have inconsistent arguments

Reported by: mdawaffe Owned by: mdawaffe
Milestone: 2.9 Priority: normal
Severity: major Version:
Component: General Keywords: has-patch dev-feedback
Focuses: Cc:

Description

added_{$meta_type}_meta: $wpdb->insert_id, $object_id, $meta_key, $meta_value

update_{$meta_type}_meta: $object_id, $meta_key, $meta_value, $meta_id

In the former, $meta_id is first. In the later, $meta_id is last.

They should have the same argument order.

Attachments (2)

11125.diff (465 bytes) - added by mdawaffe 4 years ago.
11125.b.diff (999 bytes) - added by mdawaffe 4 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 follow-up: mdawaffe4 years ago

delete_metadata calls the following hook:

deleted_{$meta_type}_meta: $object_id, $meta_key, $meta_value, $meta_ids

I suggest all the metadata hooks use that order (object_id, key, value, meta_id).

mdawaffe4 years ago

comment:2 mdawaffe4 years ago

  • Keywords has-patch dev-feedback added
  • Owner set to mdawaffe
  • Status changed from new to accepted

mdawaffe4 years ago

comment:3 in reply to: ↑ 1 mdawaffe4 years ago

  • Severity changed from normal to major

Replying to mdawaffe:

I suggest all the metadata hooks use that order (object_id, key, value, meta_id).

That suggestion is a bad one.

The actions need to have arguments in the following order instead.

meta_id(s), object_id, key, value

I didn't realize that in addition to the (added|updated|update|deleted)_{$meta_type}_meta actions, there were already pre-existing (added|updated|update|deleted)_(post|user)_meta actions. These pre-existing actions all use the above argument order.

New patch puts them in the correct order.

Bumping severity since it's now a real bug, not just a new inconsistency.

comment:4 ryan4 years ago

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

(In [12173]) Fix argument order. Props mdawaffe. fixes #11125

Note: See TracTickets for help on using tickets.