Opened 9 years ago
Closed 9 years ago
#35652 closed defect (bug) (fixed)
update_metadata() does twice as many loops through pre/post update actions as needed
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
In update_metadata() WordPress iterates through all of the updated meta ids four times. Once each for the following actions:
update_postmeta
update_{$meta_type}_meta
updated_{$meta_type}_meta
updated_postmeta
Making separate loops for both update and then both updated actions is uneeded. Yes, it's a small thing, but if lots of meta ids are being updated for same key, or lots of keys are being updated, or lots of keys with many meta ids per each, it could make a difference.
My patch simplifies the code to two loops. I think it makes it more readable.
A case <em>might</em> be made that the having updated_postmata
and updated_post_meta
is also redundant, but not sure that's worth deprecating and sounds like a different ticket.
Attachments (1)
Change History (4)
#1
@
9 years ago
- Milestone changed from Awaiting Review to 4.5
- Owner set to boonebgorges
- Status changed from new to assigned
Yeah, this seems like a good change. There's a slight possibility for breakage, because now if you have meta_ids [1, 2, 3]
, the order of actions fired will change.
Currently:
update_post_meta 1 update_post_meta 2 update_post_meta 3 update_postmeta 1 update_postmeta 2 update_postmeta 3
After the patch:
update_post_meta 1 update_postmeta 1 update_post_meta 2 update_postmeta 2 update_post_meta 3 update_postmeta 3
I'm having a hard time coming up with a scenario where this would cause a real problem (in what scenarios is one legitimately using both hooks? and in what percentage of those cases does order matter? sounds like a race condition waiting to happen, even without the proposed change). But I want to note it for the record.
Patch for 35652