WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 3 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)

29415.patch (1.6 KB) - added by ethitter 5 years ago.

Download all attachments as: .zip

Change History (10)

#1 @rmccue
5 years ago

Also note, nacin on #27003:

I figure that wp_get_network() will eventually start returning a proper object, so I wanted to go ahead with this abstraction now. Also, originally, there was some decoration that occurred in wp_get_network(). It doesn't matter for the moment. That said, emphasizing that a DB row should be passed through to wp_get_network() sets a good standard for others to do so, which means the migration to a proper object might be smoother.

With this, we might want to look at actually making those objects.

@ethitter
5 years ago

#2 @ethitter
5 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.

#3 @jeremyfelt
4 years ago

  • Milestone changed from Awaiting Review to Future Release

#4 @wonderboymusic
4 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

#5 @jeremyfelt
4 years ago

We should probably do this hand in hand with WP_Network_Query in #32504.

#6 @jeremyfelt
4 years ago

  • Milestone changed from 4.4 to Future Release
  • Owner jeremyfelt deleted

Pushing this back to Future Release until we have better groundwork.

This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.


3 years ago

#8 @jeremyfelt
3 years ago

I forgot about this ticket while we were working on #32504. Now that get_networks() is available, we should be able to consider this closed.

Thoughts?

#9 @jeremyfelt
3 years ago

  • Keywords needs-refresh removed
  • Milestone changed from Future Release to 4.6
  • Resolution set to fixed
  • Status changed from assigned to closed

Considering this fixed via [37895].

Note: See TracTickets for help on using tickets.