[wp-trac] [WordPress Trac] #37958: Improve looping through sites and restoring
WordPress Trac
noreply at wordpress.org
Thu Jan 26 21:57:19 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 johnjamesjacoby):
`WP_Locale_Switcher:: restore_current_locale()` does exactly what
`restore_site_state()` does.
If we do end up with a switcher class, I don't think we need a fourth
layer of API's around globals, objects, and procedures.
Also, the proposed patch here is kinda doing-it-wrong. Why create a local
variable to encapsulate the states of a few globals when you can already
look at the globals directly or avoid them procedurally?
In the `get_site_state()` function, a new `WP_Site_State` object is
created with each call, so we'd end up with many copies of those globals
with different signatures in PHP that will consume an ever increasing
amount of memory when used multiple times within the same scope.
I think this is trying to solve a problem that doesn't exist, and
introduces more complexity than it adds value.
---
Consider also that this patch is not a backwards compatible replacement
for what's in core, because the `switch_blog` action does not get fired on
the way out of the iterator anymore, only at the beginning. And currently,
the switched stack is only really ever 2 items deep, not several, though
it's certainly possible to do so on your own.
Not gonna lie, it's gonna be hard to win me over on this one. :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37958#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list