WordPress.org

Make WordPress Core

Opened 4 months ago

Closed 3 months ago

#41762 closed enhancement (fixed)

Use WP_Network_Query in ms_load_current_site_and_network

Reported by: spacedmonkey Owned by: flixos90
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.6
Component: Networks and Sites Keywords: has-patch
Focuses: multisite Cc:

Description (last modified by spacedmonkey)

Use WP_Network_Query in ms_load_current_site_and_network instead of raw SQL query.

Attachments (2)

41762.diff (1.4 KB) - added by spacedmonkey 4 months ago.
41762.2.diff (1.6 KB) - added by flixos90 3 months ago.

Download all attachments as: .zip

Change History (11)

#1 @spacedmonkey
4 months ago

  • Description modified (diff)
  • Summary changed from Use get_networks in ms_load_current_site_and_network to Use WP_Network_Query in ms_load_current_site_and_network

@spacedmonkey
4 months ago

#2 @spacedmonkey
4 months ago

Replace raw sql to the sites table with wp_network_query. Number of briefs to this, wp_network_query has filters that are run. Also network queries also have caching out of the box.

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


3 months ago

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


3 months ago

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


3 months ago

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


3 months ago

#7 @flixos90
3 months ago

  • Milestone changed from Awaiting Review to 4.9
  • Owner set to flixos90
  • Status changed from new to reviewing

Let's keep the current-network cache in place for now, as it's less aggressively invalidated compared to the cache used by WP_Network_Query.

@flixos90
3 months ago

#8 @flixos90
3 months ago

41762.2.diff keeps the current-network cache key in place, and removes the now unused $wpdb global.

#9 @flixos90
3 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 41718:

Multisite: Use WP_Network_Query in ms_load_current_site_and_network().

This gets rid of the last readonly direct database query for networks in core. 🎉

Props spacedmonkey.
Fixes #41762.

Note: See TracTickets for help on using tickets.