[wp-trac] [WordPress Trac] #60290: Changeset #56635 breaks template loading in multisite network using switch_to_blog()
WordPress Trac
noreply at wordpress.org
Tue Jan 23 15:10:29 UTC 2024
#60290: Changeset #56635 breaks template loading in multisite network using
switch_to_blog()
--------------------------------------+--------------------------
Reporter: metropolis_john | Owner: joemcgill
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 6.5
Component: Themes | Version: 6.4.2
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: performance
--------------------------------------+--------------------------
Comment (by joemcgill):
Replying to [comment:6 manfcarlo]:
> @joemcgill can you explain how this ticket isn't the same with regard to
"undocumented and unintentional" behaviour?
Good question, @manfcarlo. I think that this case is slightly different in
that the previous behavior that changed was the expected behavior. Prior
to [56635], `locate_template()` relied on the value of constants that were
set early in a request lifecycle because the expectation is that you would
only have a single theme active during one request. `switch_to_blog()` is
a function that is meant to let you access ''data'' from another site on
the network (e.g., users, posts, options, etc.), but was not meant to
allow you to change to different parts of a filesystem. This similar to
why `switch_to_blog()` doesn't change which plugins are active (see
#14941).
#60025 was relying on behavior that was a side-effect of the previous
implementation, in which you could trick WP into using the current theme's
root directory, but then loading templates from a different sub-directory,
based on a race condition between when the constants were set and when
filters were registered. Even so, the approach in
[https://github.com/WordPress/wordpress-develop/pull/5926 this PR] might
restore the previous (undocumented) behavior for #60025 as well.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60290#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list