Opened 10 years ago
Closed 10 years ago
#37218 closed enhancement (fixed)
get_main_network_id should use WP_Network_Query
| Reported by: | spacedmonkey | Owned by: | jeremyfelt |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.7 |
| Component: | Networks and Sites | Version: | 4.6 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | multisite |
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
@
10 years ago
- Owner set to
- Status new → 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
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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).