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

WordPress Trac noreply at wordpress.org
Tue Feb 24 22:55:14 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 apermo):

 Copied from https://github.com/WordPress/wordpress-
 develop/pull/8688#discussion_r2849835015

 While preparing an answer for @westonruter I found this:

 https://github.com/search?q=repo%3AWordPress%2Fwordpress-
 develop%20%22SELECT%20DISTINCT%20YEAR(%20post_date%20)%20AS%20year%2C%20MONTH(%20post_date%20)%20AS%20month%22&type=code

 The query is basically called 4 times throughout core, with minor changes,
 and in /wp-admin/include/media.php even without a prepare.

 Two related two attachments and basically copy and paste. The other two
 slight variants but close.

 I'm thinking of at least using the newly introduced function in both
 cases. What are your thoughts? Make a reuseable function for all 4, or
 just the 2 attachments queries?

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


More information about the wp-trac mailing list