[wp-trac] [WordPress Trac] #64719: Optimize themes REST collection request when querying active theme

WordPress Trac noreply at wordpress.org
Tue Feb 24 21:18:53 UTC 2026


#64719: Optimize themes REST collection request when querying active theme
-----------------------------------+-----------------------------
 Reporter:  aduth                  |      Owner:  (none)
     Type:  enhancement            |     Status:  new
 Priority:  normal                 |  Milestone:  Awaiting Review
Component:  REST API               |    Version:
 Severity:  normal                 |   Keywords:
  Focuses:  rest-api, performance  |
-----------------------------------+-----------------------------
 The [https://github.com/WordPress/wordpress-
 develop/blob/6cd1f7d48cf58d3c9dee30e1c8e3eaf55ae8e523/src/wp-includes
 /rest-api/endpoints/class-wp-rest-themes-controller.php#L189-L220 current
 implementation of `WP_REST_Themes_Controller#get_items`] always calls
 `wp_get_themes`, which is
 [https://developer.wordpress.org/reference/functions/wp_get_themes/
 documented as "quite expensive, and grows linearly with additional
 themes"]. When requesting themes with `status=active`, we know that we're
 only interested in the active theme, so it's wasteful to call
 `wp_get_themes` and loop over all of the available themes. Instead, we can
 shortcut and return the current theme directly.

 This could have a noticeable performance impact on Gutenberg, which
 queries active themes in several places, like its
 [https://github.com/WordPress/gutenberg/blob/0180c417fc4d2e704f3f8738ed09703ebeeda189/packages
 /core-data/src/resolvers.js#L594-L607 `getCurrentTheme`] and
 [https://github.com/WordPress/gutenberg/blob/0180c417fc4d2e704f3f8738ed09703ebeeda189/packages
 /core-data/src/resolvers.js#L784-L807
 `__experimentalGetCurrentGlobalStylesId`] selectors.

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


More information about the wp-trac mailing list