[wp-trac] [WordPress Trac] #37958: Improve looping through sites and restoring
WordPress Trac
noreply at wordpress.org
Tue Sep 6 18:28:34 UTC 2016
#37958: Improve looping through sites and restoring
--------------------------------+-------------------------------------
Reporter: tfrommen | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Networks and Sites | Version:
Severity: normal | Resolution:
Keywords: | Focuses: multisite, performance
--------------------------------+-------------------------------------
Comment (by tfrommen):
Replying to [comment:2 johnjamesjacoby]:
> I've always felt this type of approach is most useful when you already
know ahead of time an array of site ID's you want to quickly switch
between. If we can count on that always being true, maybe the way to
implement this is actually on-top of the existing API with a `$quick`
parameter, and a `stash_current_blog()` helper that gets called before the
loop happens.
How would the `stash_current_blog()` and the ''quick'' `switch_to_blog(
$id, true )` functions work exactly?
The main difference between our approaches is that your code actively
works with (and '''in''') the global scope, while my implementation does
not. If I create a `NetworkState` object and call its `restore` method, I
know exactly what I get.
Your example breaks, if you call something in the loop that stashes the
current (already switched) site on its own.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37958#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list