WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 8 months ago

Last modified 8 months ago

#37922 closed defect (bug) (fixed)

WP_Site_Query does not have a $join query clause to compact

Reported by: johnjamesjacoby Owned by: jeremyfelt
Milestone: 4.7 Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: has-patch commit
Focuses: multisite Cc:

Description

The new WP_Site_Query class tries to compact() the join variable, which will never exist because there are no related tables to join against.

Recommend we either:

  • Add join clause & $join = ''; to get_site_ids()
  • Remove join from compact() statement

Attachments (2)

37922.patch (574 bytes) - added by johnjamesjacoby 9 months ago.
Add
37922.2.patch (495 bytes) - added by johnjamesjacoby 9 months ago.
Remove

Download all attachments as: .zip

Change History (9)

@johnjamesjacoby
9 months ago

Add

@johnjamesjacoby
9 months ago

Remove

#2 @flixos90
9 months ago

I would say we add it in as empty as developers filtering the clauses may expect the key to exist. It also looks a bit more future-proof that way.

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


8 months ago

#4 @flixos90
8 months ago

  • Keywords commit added; 2nd-opinion removed
  • Milestone changed from Awaiting Review to 4.7

This can be committed, using the first patch.

Last edited 8 months ago by flixos90 (previous) (diff)

#5 @jeremyfelt
8 months ago

I think we can follow what we're doing in WP_Network_Query and make $join available to the sites_clauses filter (where it could be used) but not yet add it to the sql_clauses property (where it wouldn't yet be used).

#6 @jeremyfelt
8 months ago

  • Owner set to jeremyfelt
  • Resolution set to fixed
  • Status changed from new to closed

In 38631:

Multisite: Provide $join as a possible SQL clause to the sites_clauses filter.

Previously, compact() provided a non existent $join and could cause confusion for anyone attempting to extend WP_Site_Query with their own tables. This aligns with the current behavior in WP_Network_Query.

Props johnjamesjacoby.
Fixes #37922.

#7 @johnjamesjacoby
8 months ago

Good catch on not needing to add join to $sql_clauses. Thanks @jeremyfelt!

Note: See TracTickets for help on using tickets.