[wp-trac] [WordPress Trac] #27003: Introduce wp_get_network() and begin cleanup of multisite load

WordPress Trac noreply at wordpress.org
Thu Feb 20 06:06:06 UTC 2014


#27003: Introduce wp_get_network() and begin cleanup of multisite load
--------------------------------------------------+------------------------
 Reporter:  jeremyfelt                            |       Owner:
     Type:  enhancement                           |      Status:  new
 Priority:  normal                                |   Milestone:  3.9
Component:  Bootstrap/Load                        |     Version:  trunk
 Severity:  normal                                |  Resolution:
 Keywords:  has-patch needs-testing dev-feedback  |     Focuses:  multisite
--------------------------------------------------+------------------------

Comment (by nacin):

 I think everything (even the old stuff) should actually be wp_cache_add().
 There's no reason for an unconditional set. If it already exists
 somewhere, we should bail. (set() forces a cache update, even across
 multiple servers, which isn't necessary when we are simply caching a value
 that wasn't already cached, versus updating an invalid value.)

 While a 'networks' bucket is good to think about, it's not a declared
 global bucket. Let's keep using site-options to keep it clean.

 The one problem with this is it'll result in a new cache key for every
 unique URI request. That's a ''lot'' of cache writes. The second thing to
 think about is that get_network_by_path() is actually the cheaper
 function. The networks table will without a doubt smaller than the blogs
 table, and it's often sped up or bypassed via a constant, or there being
 only one network (this is a cached state, though populate_network() should
 clear that cache), or by their being no networks with paths. The function
 is also only used in one situation, and only because we're only searching
 one path level (past the network's path, which is why we need it). Caching
 the get_site_by_path() request is going to be more useful.

 If networks_have_paths is false, then we only need the domain in the cache
 key. Or even better, this is when networks_have_paths comes in useful. Now
 that I think about it, if no networks have a path, then we don't actually
 need to run get_network_by_path(), and can instead go right to
 get_site_by_path().

 We can actually leverage networks_have_paths also outside of
 get_network_by_path() as a way to replace the is_subdomain_install()
 check. As it is now, if you're running a "subdomain" install and add a
 network with a path, you'd have to add your own handling (well, adjust one
 of the new filters) to make sure any deeper-pathed sites off that network
 are handled. Instead, we can simply use networks_have_paths as a
 barometer. No current subdomain install would be adversely affected, as
 none of them have a network with a path. Presumably.

 Not going to lie, I kind of just want to load all networks into memory and
 bypass that whole mess.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27003#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list