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_prefix are 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_prefix at runtime when the
key() method is called. This ensures that the
$blog_id used in the prefixes is proper.
I also patched it so that the
$blog_id is 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
preg_replace was misplaced.
See patch: https://gist.github.com/4254249