[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:02:15 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: trunk
Severity: minor | Keywords: needs-patch
Focuses: multisite |
--------------------------+-----------------------------
`WP_Theme->get_post_templates` relies on global `themes` cache group. This
means that the same results are being used on every subsite in a network.
In the past, it did not lead to issues, but now, with FSE, page templates
can be created in admin area, which complicates things.
`get_block_templates` function that is used in
`WP_Theme->get_post_templates` loads templates created on subsite and
later on caches those results. This leads to all sites in a network
accessing the same cached results - site A can end up seeing templates of
site B when editing a page. This becomes especially problematic if
`wp_cache_themes_persistently` filter returns `true`.
I think the solution here should be to move `get_block_templates` related
code outside of cache regeneration part. This way, templates from files
would be cached globally, but block templates would be unique per site in
a network.
Am I missing anything? If not, I can prepare PR for that.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57886>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list