Opened 10 years ago
Closed 8 years ago
#29415 closed enhancement (fixed)
$sites global (containing all networks) no longer exists, with no replacement
Reported by: | rmccue | Owned by: | |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | Networks and Sites | Keywords: | has-patch |
Focuses: | multisite | Cc: |
Description
#27003 removed the $sites
global containing an array of networks on the installation. This broke the switch_to_network
functionality of WP Multi Network, as it expected this variable to be set.
Given that we've gone almost a whole release without anyone missing it, I think it's fine to leave it gone forever. That said, there appears to be no replacement to get all networks.
We should add a wp_get_networks
, and it should also cache this result. wp_get_network
could then be adapted to take advantage of this cache if it exists.
Related: #29411
Attachments (1)
Change History (10)
#2
@
10 years ago
29415.patch is a basic start for wp_get_networks()
.
The function supports basic arguments--domain, path, limit, and offset--for which networks are to be retrieved. Like wp_get_sites()
, the results from $wpdb
are returned directly as an associative array.
I consciously left caching out of this first pass; I'm not sure how beneficial it will be. On an instance with only a few networks, the cache lookup may not be any faster than the DB lookup. On a large network where there may be a benefit, storing all networks in a single array could encounter issues with cache value sizes.
This needs tests as well, but I'm looking first for feedback on arguments and the need for caching. Without any use cases in Core currently, it's hard to anticipate deficiencies in my initial approach.
#4
@
9 years ago
- Keywords has-patch needs-refresh added
- Milestone changed from Future Release to 4.4
- Owner set to jeremyfelt
- Status changed from new to assigned
I am assuming this needs a refresh
#6
@
9 years ago
- Milestone changed from 4.4 to Future Release
- Owner jeremyfelt deleted
Pushing this back to Future Release until we have better groundwork.
Also note, nacin on #27003:
With this, we might want to look at actually making those objects.