[wp-trac] [WordPress Trac] #37958: Improve looping through sites and restoring
WordPress Trac
noreply at wordpress.org
Fri Jan 27 08:31:30 UTC 2017
#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 flixos90):
I agree with @swissspidy that we're talking about two things here.
In my opinion, creating a `WP_Site_Switcher` class that works similarly to
`WP_Locale_Switcher` should be the first iteration. It would allow us to
get rid of the globals (needs-dev-note still, just for the edge-case
someone directly accesses these). As far as this thread goes, I don't
think there's anything in the way of doing that.
For the second step, I see @tfrommen's idea just as valuable. While
switching and restoring a site are fortunately rather inexpensive
operations, there's still unnecessary overhead when always switching back
(restoring).
Backward-compatibility is a concern as @johnjamesjacoby mentioned, but I
think it only is a concern if we change the core code to use it in areas
where it already exists. To be a 100% safe, we could only apply the new
idea to new code. But even if we use it elsewhere, it might not be that
terrible in my opinion. The `switch_blog` hook only fires when a site is
switched. Whether it actually switches or just restores, shouldn't matter.
I know it has been a convention to always restore immediately afterwards,
but I generally don't see any harm in going deeper into the stack. As we
would need a dev-note for any of these changes anyway, I think we can
carefully explain the changes and make people aware. @johnjamesjacoby Do
you have a specific use-case where this would be a problem?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37958#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list