[wp-trac] [WordPress Trac] #29684: Add get_main_site_id() function
WordPress Trac
noreply at wordpress.org
Fri Jul 28 11:20:25 UTC 2017
#29684: Add get_main_site_id() function
--------------------------------------+-------------------------
Reporter: rmccue | Owner: jeremyfelt
Type: enhancement | Status: reviewing
Priority: normal | Milestone: 4.9
Component: Networks and Sites | Version: 3.9
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: multisite
--------------------------------------+-------------------------
Comment (by spacedmonkey):
Saving in in network options, there were a couple of reason.
1. To cache the result. The main site will likely never change. Because of
this fact, it should be stored. This saves doing any queries on the blogs
table. Take for example a network with 25k sites and 57 networks and no
object cache enabled. That get_sites lookup could be expensive. Calling
from a network option is a much faster lookup.
2. Saving it in network option makes it easier to change the main site.
You can change it using the filter, but then you have to maintain the
filter function forever more. Seems clearer to just store it.
3. Storing it in the network option makes the lookup much easier. How easy
is it to find list of a main sites?
4. In #37181 `wp_load_core_site_options` primes all the network options.
So this main option would be primed in memory anyway.
I am not sure I understand your point about `populate_network`. I added
the network option in there and seems like network id and site id (blog
id) are available at the point, what is the issuing in saving it?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29684#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list