[wp-trac] [WordPress Trac] #63279: Improve `media_library_months_with_files` inside `wp_enqueue_media()`

WordPress Trac noreply at wordpress.org
Mon Feb 23 20:07:01 UTC 2026


#63279: Improve `media_library_months_with_files` inside `wp_enqueue_media()`
-------------------------+-----------------------------
 Reporter:  apermo       |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Future Release
Component:  Media        |     Version:  4.7.4
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  performance
-------------------------+-----------------------------

Comment (by dmsnell):

 There’s a clear need articulated in this ticket and I think it’s
 warranted; while it’s possible to intercept the `'query'` hook and rewrite
 the attachment query, that encourages hard-coding internals in the plugin
 space. Having a reusable base query provides the behavior without
 encouraging those awkward couplings.

 That being said I am not of the same opinion that we should combine this
 change with the introduction of a new caching layer. When all we are doing
 is extracting the internal process for reuse, there are no architectural
 impacts of this change. When we add a default caching layer there are
 brand new issues to consider, potentially-surprising performance impacts,
 and cache-invalidation problems.

 I would be far more inclined to merge this without any transients or
 caches, leaving the state as it is and up to plugins, and wait and see if
 there’s even a justification for default caching here. As I understand it,
 this patch is not only about the performance characteristics of the
 database query itself, but of the entire system reliant on the results, as
 well as the UX impact of showing everything inside a massive library.

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


More information about the wp-trac mailing list