I’m working on a multisite instance which includes some cross-posting functionality, allowing you to publish a post on one blog and then to have a that same post shallow-copy onto other blogs on the network. When this shallow copy is rendered on the other blogs, it wraps
the_content()in calls to
switch_to_blog($original_blog_id)/restore_current_blog()so that galleries and other shortcodes will continue to function as they do on the original blog. I encountered issues with this functionality when Memcached Object Cache is enabled.
The issue seems to be that the
$global_prefixare defined once upon initialization instead of when the cache key is generated, so that once
switch_to_blog()is called the cache key is not valid anymore. I fixed the issue by determining
$global_prefixat runtime when the
key()method is called. This ensures that the
$blog_idused in the prefixes is proper.
I also patched it so that the
$blog_idis added even to the
$global_prefix, just to make certain that the caches the blogs would not pollute each other.
Lastly, I fixed some apparently broken logic surrounding the incorporation of
WP_CACHE_KEY_SALT. It seemed the closing paren for
See patch: https://gist.github.com/4254249
- The topic ‘Issue with multisite and use of switch_to_blog()’ is closed to new replies.