[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
Wed Feb 18 19:57:08 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:  assigned
 Priority:  low                      |   Milestone:  7.0
Component:  Cache API                |     Version:  3.0
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  multisite
-------------------------------------+------------------------------

Comment (by johnjamesjacoby):

 23290-4.patch is a riskier side quest - same as 23290-3.patch but:

 * Removes the hard-coded calls to `wp_cache_switch_to_blog()` inside of
 `switch_to_blog()` and `restore_current_blog()`
 * Adds `wp_cache_switch_to_blog` to the `switch_blog` hook, inside of `ms-
 default-filters.php`

 This works because `wp_cache_switch_to_blog()` will always exist now,
 which allows us to decouple the Cache API from the Blog Switching API,
 similar to how the Roles API and `wp_switch_roles_and_user()` is.

 I consider this risky because it hides an important function call that has
 always been an obvious one. But it is neat so I thought I'd suggest it
 too.

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


More information about the wp-trac mailing list