Make WordPress Core

Opened 7 years ago

Last modified 5 years ago

#42284 new defect (bug)

Stop invalid query generation in WP_Site_Query

Reported by: spacedmonkey's profile spacedmonkey Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.6
Component: Networks and Sites Keywords:
Focuses: multisite Cc:


In WP_Site_Query, developers have the ability to query by a single value or by multiple using a __in param. An example of which is which is domain and domain__in. Take for example the following query.

get_sites(=> 'test.local', 'domain__in' => ['lebowski.local', 'start.test.local'?]);

This query will only results for test.local, completely ignoring the domain__in. This is because of the query it generates. That looks like this

domain = 'test.local' AND domain IN ('lebowski.local', 'start.test.local')

Improved error checking must be implemented on this code to stop invalid queries.

Attachments (1)

42284.diff (5.3 KB) - added by spacedmonkey 7 years ago.

Download all attachments as: .zip

Change History (5)

7 years ago

#1 @spacedmonkey
7 years ago


This is a first patch. This is not finished as it does have tests. Uploaded as a talking point. My work around is move all single values to the multi values. This way, all queries are doing a IN search. This should have any effect on performance, but will make better results be returned.

Also notice the placement of the tidy of query, after filter has been run, maintaining backwards compatibility.

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

6 years ago

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

5 years ago

Note: See TracTickets for help on using tickets.