[wp-trac] [WordPress Trac] #35652: update_metadata() does twice as many loops through pre/post update actions as needed

WordPress Trac noreply at wordpress.org
Fri Jan 29 01:43:29 UTC 2016


#35652: update_metadata() does twice as many loops through pre/post update actions
as needed
--------------------------+-----------------------------
 Reporter:  Shelob9       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35652>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list