[wp-trac] [WordPress Trac] #49446: cache the results of get_uploaded_header_images()

WordPress Trac noreply at wordpress.org
Sun Feb 16 14:57:34 UTC 2020


#49446: cache the results of get_uploaded_header_images()
-------------------------+------------------------------------------
 Reporter:  pbiron       |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Cache API    |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  administration, performance
-------------------------+------------------------------------------

Comment (by pbiron):

 Replying to [comment:2 SergeyBiryukov]:
 > Even with caching added, saving `$header_images` to a static variable in
 `_media_states()` seems like a quick win to avoid having to go through
 `wp_list_pluck()` for the result of `get_uploaded_header_images()` for
 every row.

 Agreed...that's kind how I stumbled on this.  I've got a custom plugin
 that does a relatively complex query hooked to `display_media_states` and
 storing the results in a `static` sped things up considerably.

 I went looking for more improvements and was going to suggest exactly the
 patch you added...then found that inline comment about caching in
 `get_uploaded_header_images()` :-)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49446#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list