[wp-trac] [WordPress Trac] #14992: When Object Caching is enabled switch_to_blog causes issues with some functions
WordPress Trac
wp-trac at lists.automattic.com
Thu Sep 30 10:22:04 UTC 2010
#14992: When Object Caching is enabled switch_to_blog causes issues with some
functions
---------------------------+------------------------------------------------
Reporter: simonwheatley | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Multisite | Version:
Severity: major | Keywords: dev-feedback
---------------------------+------------------------------------------------
Comment(by hakre):
Switch to blog is database only. Object Cache is not database.
Strictly spoken, this is not a bug.
As scribu already reported, this function is often not properly understood
and therefore probably misused in some places. And as this ticket implies
some of us might need more functionality in switching blogs, not only for
the database context but also for the object-cache.
I suggest to refactor switch_to_blog into switch_to_blog_database() and
deprecate the older one/change it's use to switch every context available
for a switch (e.g. database and then probably soon objectcache).
Then other developers can implement new and needed functionality in
similar named functions like switch_to_blog_objectchache().
Just a raw idea:
{{{
function switch_to_blog($blogid) {
$blogid = normalize_blogid($blogid);
if (!is_valid_blogid($blogid))
return false;
current_blogid = get_current_blogid();
if (!switch_to_blog_database($blogid)) {
return false;
}
if (!switch_to_blog_objectcache($blogid)) {
switch_to_blog_database($current_blogid);
return false;
}
return $blogid;
}
}}}
In contrast to my argumentation in #14953, I think that the object-cache
as it is something quite related to the database, should be able to switch
as well and it should be useful to provide that functionality as well
ASAP. I wonder how wordpress.com is dealing with such issues, assuming
that they should have a setup when this comes into play. Maybe some wpcom
devs can provide some useful feedback.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14992#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list