Opened 8 years ago
Closed 8 years ago
#37218 closed enhancement (fixed)
get_main_network_id should use WP_Network_Query
Reported by: | spacedmonkey | Owned by: | jeremyfelt |
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 4.6 |
Component: | Networks and Sites | Keywords: | has-patch |
Focuses: | multisite | Cc: |
Description
The get_main_network_id is used in the bootstrap process to load the network object. With the new WP_Network_Query class, we should use that to load the network id. Using WP_Network_Query we gain filters and caching.
Attachments (2)
Change History (6)
#3
@
8 years ago
- Owner set to jeremyfelt
- Status changed from new to reviewing
Replying to flixos90:
One thing I don't think we need is the
! empty( $_networks )
check. That kind of check hasn't been in place before and shouldn't be required since every Multisite has at least one network.
Agreed. I don't believe there's a way to hit that condition unless something has gone very wrong. I think we're okay without it. I've added 37218.4.diff, which makes that change.
About unit tests, I don't think these are necessary here since that part of
get_main_network_id()
is already covered (https://core.trac.wordpress.org/browser/trunk/tests/phpunit/tests/multisite/network.php#L66 would fail if we broke it).
+1
Patch looks good to me. +1 for getting rid of the cache key. One thing I don't think we need is the
! empty( $_networks )
check. That kind of check hasn't been in place before and shouldn't be required since every Multisite has at least one network.About unit tests, I don't think these are necessary here since that part of
get_main_network_id()
is already covered (https://core.trac.wordpress.org/browser/trunk/tests/phpunit/tests/multisite/network.php#L66 would fail if we broke it).