[wp-trac] [WordPress Trac] #57886: get_post_templates includes results of get_block_templates while caching (WP_Theme)

WordPress Trac noreply at wordpress.org
Wed Mar 8 14:32:28 UTC 2023


#57886: get_post_templates includes results of get_block_templates while caching
(WP_Theme)
--------------------------+-------------------------------------
 Reporter:  maniu         |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Themes        |     Version:  5.9
 Severity:  minor         |  Resolution:
 Keywords:  needs-patch   |     Focuses:  multisite, performance
--------------------------+-------------------------------------
Changes (by spacedmonkey):

 * focuses:  multisite => multisite, performance
 * version:  4.7 => 5.9


Comment:

 Okay, I see the issue.

 If you set `wp_cache_themes_persistently` to true by filter, are running
 multisite, are using a block theme and have custom templates in the
 database, then as themes is a global cache, then the last site to change
 the cache, will overwrite changes.

 As this is FSE related, I am changing this to 5.9 version.

 This is an oversite when this was created. Sadly there is not a simple
 solution for this. [https://github.com/WordPress/wordpress-
 develop/blob/7945c0ce1989408a1b6c99308ddcf1b3d5df572c/src/wp-includes
 /class-wp-theme.php#L1290-L1305 This] is the code that is the problem.

 Some possibly solutions.

 - If the theme is a block theme, make the cache group not a global cache
 group.
 - Prefix the template with the site id.
 - Do not cache this data.


 All of these have their downside. I am going to assign this to myself, so
 I can take a look into it. Also going to ping the performance lead
 @flixos90 for his thoughts on it.

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


More information about the wp-trac mailing list