Make WordPress Core

Opened 14 months ago

Last modified 8 days ago

#38025 new enhancement

Query networks with meta_query

Reported by: johnjamesjacoby Owned by:
Milestone: 5.0 Priority: normal
Severity: normal Version: 4.6
Component: Networks and Sites Keywords: needs-patch 2nd-opinion ms-roadmap
Focuses: multisite Cc:


It would be great to add a meta_query parameter to WP_Network_Query.

I have a need to do this in my WP Multi Network plugin, to query for networks by the site_admin meta key. I'd also like to be able to orderby the blog_count meta key & value.

Related: #32504

Change History (7)

#1 @flixos90
14 months ago

Theoretically a definitive +1 for me, but we first need to decide how we are going to see network options in the future. There have been several discussions in Multisite weekly chat (latest discussion: https://wordpress.slack.com/archives/core-multisite/p1472575431000080), I hope we can come to a decision soon. At the moment for example, calling this parameter meta_query would be weird because this kind of data is commonly known as network options.

Btw the original patch for WP_Network_Query had this functionality, but it was stripped out for the above reasons. See https://core.trac.wordpress.org/ticket/32504#comment:22 (for the patch, see https://core.trac.wordpress.org/attachment/ticket/32504/32504.4.diff).

Also in order for this idea to work properly, we would need to use the Meta API for network options (at least internally, see #37181) so that cache invalidation works.

#2 @spacedmonkey
12 months ago

I little back story on this one for anyone new to the ticket. @flixos90 's orignal patch did have the meta query in it, but pretty late in the ticket, I asked for it to be removed. There were issues with cache invalidation when you changed the network option. It meant for example, you changed site 2 network option "name" from test to example, the query with a meta query, will still return site 2 for a meta query for "test". It was removed in hopes to put it back in later.

My personal view is the network options (that are formatted as site network meta in the db) should be treated like other object types meta. I have a ticket #37181 open to change in the internals of the *_network_options functions to use the metadata api. I know this is a big change, but opens a lot of doors in the future. Until we decide what is happening with how network options are thought of in core, this ticket will not progress.

I believe that @flixos90 & @johnjamesjacoby and myself have made our feelings clear about making network option more like meta. But I know that @jeremyfelt had his issues with the idea. Would like if we worked on this ticket in 4.8

Related: #37181

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

4 months ago

#4 @flixos90
4 months ago

  • Keywords ms-roadmap added

These tickets belong to our planned roadmap (a few of them not per final decision), so flagging with a keyword for better overview.

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

4 months ago

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

3 months ago

#7 @spacedmonkey
8 days ago

  • Keywords changed from needs-patch, 2nd-opinion, ms-roadmap to needs-patch 2nd-opinion ms-roadmap
  • Milestone changed from Awaiting Review to 5.0
Note: See TracTickets for help on using tickets.