[wp-trac] [WordPress Trac] #58758: Cached result for wp_theme_has_theme_json() is not invalided when theme is switched dynamically

WordPress Trac noreply at wordpress.org
Mon Jul 10 09:45:40 UTC 2023


#58758: Cached result for wp_theme_has_theme_json() is not invalided when theme is
switched dynamically
--------------------------+--------------------------
 Reporter:  westonruter   |       Owner:  westonruter
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  6.2.3
Component:  Themes        |     Version:  6.2
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  performance
--------------------------+--------------------------

Comment (by spacedmonkey):

 I agree that the current implementation is problematic. It basically guess
 that the stylesheet will not change in the course of a php request.

 I have discussed added a parameter to the function in
 [https://github.com/WordPress/gutenberg/pull/45955 #45955]. Little out of
 scope this, but related.

 I also explored adding a method to the WP_Theme class, which would make
 context aware as well and would add caching. [https://github.com/WordPress
 /wordpress-develop/pull/3860 #3860]

 I think the best solution to this would be make `$theme_has_support` an
 array and use the stylesheet as a key. This would allow for themes to be
 switched and the key would change.

 I put together a PR for review. [https://github.com/WordPress/wordpress-
 develop/pull/4820 #4820].

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


More information about the wp-trac mailing list