[wp-trac] [WordPress Trac] #14418: Introduce restore_original_blog()
WordPress Trac
wp-trac at lists.automattic.com
Mon Jul 26 08:11:19 UTC 2010
#14418: Introduce restore_original_blog()
--------------------------+-------------------------------------------------
Reporter: nacin | Owner:
Type: defect (bug) | Status: new
Priority: lowest | Milestone: 3.1
Component: Multisite | Version:
Severity: normal | Keywords:
--------------------------+-------------------------------------------------
While working on a multisite install, I saved a number of queries by
switching from one blog to the next using switch_to_blog() without calling
restore_current_blog() each time. That meant I needed to rewind everything
back to the original blog when I was done.
This seems like a candidate worthy for core. It is only a few lines of
code, but it prevents users from mucking with one of the globals in
switch_to_blog() and restore_current_blog().
{{{
function restore_original_blog() {
global $switched;
while ( $switched )
restore_current_blog();
}
}}}
Alternatively, we could simply add a parameter to restore_current_blog()
(which really should be called restore_previous_blog(), no?) that allows
for a complete rewind, or perhaps steps.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14418>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list