Skip to content
Browse files

Use the global $table_prefix in switch_to_blog()

When using batcache in combination with memcached object cache on a single site install, table_prefix is not available when switch_to_blog is called. This causes two versions of data to be stored in memcached.

By bringing in the global, we can be sure that table_prefix is consistent in both logged in and logged out states
  • Loading branch information...
1 parent bc1ce5e commit 116ab778cc61786c56d775ab4e2a257c8b42097c @jeremyfelt committed
Showing with 1 addition and 0 deletions.
  1. +1 −0 object-cache.php
View
1 object-cache.php
@@ -313,6 +313,7 @@ function set($id, $data, $group = 'default', $expire = 0) {
function switch_to_blog( $blog_id ) {
$blog_id = (int) $blog_id;
+ global $table_prefix;
$this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix ) . ':';
}

1 comment on commit 116ab77

Please sign in to comment.
Something went wrong with that request. Please try again.