WordPress.org

Make WordPress Core

Opened 16 months ago

Closed 3 months ago

Last modified 2 months ago

#40229 closed enhancement (fixed)

Add meta_query to wp_site_query

Reported by: spacedmonkey Owned by: flixos90
Milestone: 5.0 Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: ms-roadmap has-patch has-unit-tests needs-dev-note
Focuses: multisite Cc:

Description

Currently site query doesn't support meta query as there is no blogmeta table. However with it being added #37923 this functionally can be supported.

Along with adding support this functionality, we should start to use it in a number of place. A key example is adding the ability to search by site title in the network admin panel

Attachments (1)

40229.diff (15.3 KB) - added by flixos90 3 months ago.

Download all attachments as: .zip

Change History (16)

#1 @flixos90
16 months ago

  • Version 4.5 deleted

I suggest continuing with the site meta query functionality in #37923 for now, as we would like to work on the entire site meta feature in the format of a feature project (hosted at https://github.com/jeremyfelt/wordpress-develop).

When we get to committing, it probably makes sense to break things down to smaller parts, and then this sub-ticket here can come in handy. For now let's keep the discussion going in a centralized location (#37923).

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


12 months ago

#3 @spacedmonkey
12 months ago

  • Keywords needs-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to 4.9
  • Owner set to spacedmonkey
  • Status changed from new to assigned

#4 @flixos90
12 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.


11 months ago

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


10 months ago

#7 @flixos90
10 months ago

  • Keywords early added
  • Milestone changed from 4.9 to Future Release

#8 @flixos90
9 months ago

  • Keywords early removed
  • Milestone changed from Future Release to 5.0

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


8 months ago

@flixos90
3 months ago

#10 @flixos90
3 months ago

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed
  • Owner changed from spacedmonkey to flixos90

40229.diff implements meta query functionality in WP_Site_Query:

  • The implementation itself is trivial and straightforward. It follows mostly how other query classes do it. The orderby-meta functionality deserves an extra look because it's the most complicated part, but the provided tests confirm it works as expected.
  • class-wp-meta-query.php is loaded earlier in wp-settings.php to allow this functionality early during the multisite bootstrap process. This will fix #40948.
  • Comprehensive tests have been added for the meta query functionality, i.e. one parameterized test with 10 datasets, each testing different behavior.
  • Three additional tests have been added to verify that adding/updating/deleting site meta busts the site query cache.

#11 @flixos90
3 months ago

In 43009:

Bootstrap: Load class-wp-meta-query.php earlier in wp-settings.php.

This change is necessary to enable multisite-specific meta query functionality during the multisite bootstrap process.

Fixes #40948. See #40229.

#12 @flixos90
3 months ago

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

In 43010:

Multisite: Add meta query functionality to WP_Site_Query.

After the introduction of site metadata in [42836], it should be possible to query sites by that data.

Fixes #40229.

#13 @flixos90
3 months ago

  • Keywords needs-dev-note added

#14 @spacedmonkey
2 months ago

@flixos90 I believe you need to put some clean_blog_cache / wp_cache_set( 'last_changed', microtime(), 'sites' ); calls into add_site_meta, update_site_meta and delete_site_meta.

Otherwise meta queries will not be invalidated.

#15 @flixos90
2 months ago

@spacedmonkey This is already in place via #37923.

Note: See TracTickets for help on using tickets.