[wp-trac] [WordPress Trac] #23290: When using switch_to_blog() with a persistent object cache that lacks wp_cache_switch_to_blog() support, non-persistent groups are not maintained
WordPress Trac
noreply at wordpress.org
Fri Feb 27 19:57:44 UTC 2026
#23290: When using switch_to_blog() with a persistent object cache that lacks
wp_cache_switch_to_blog() support, non-persistent groups are not maintained
-------------------------------------------------+-------------------------
Reporter: markjaquith | Owner:
| johnjamesjacoby
Type: defect (bug) | Status: closed
Priority: low | Milestone: 7.0
Component: Cache API | Version: 3.5
Severity: normal | Resolution: fixed
Keywords: has-patch needs-testing 2nd-opinion | Focuses: multisite
-------------------------------------------------+-------------------------
Changes (by johnjamesjacoby):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"61760" 61760]:
{{{
#!CommitTicketReference repository="" revision="61760"
Cache API: Introduce fallback for when the `wp_cache_switch_to_blog()`
function is missing.
This commit protects against an edge-case where a persistent object-cache
drop-in plugin not including its own `wp_cache_switch_to_blog()` function
would cause non-persistent cache groups to go missing when switching
between sites, and includes the following changes:
* A new `wp_cache_switch_to_blog_fallback()` function in `ms-blogs.php`
which abstracts duplicated code from `switch_to_blog()` and
`restore_current_blog()` for easier unit testing
* A new `wpCacheSwitchToBlogFallback.php` file with approximately 25 new
unit tests
* Conditionally declares `wp_cache_switch_to_blog()` in `cache-compat.php`
only if it does not already exist, either via core's `cache.php` or a
drop-in plugin
With this change, WordPress no longer needs to check if the
`wp_cache_switch_to_blog()` function exists (because it always will) so
those checks have been removed.
Props ethitter, jeremyfelt, johnjamesjacoby, markjaquith, nacin, ozgursar,
r1k0.
Fixes #23290.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/23290#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list