Make WordPress Core

Opened 7 years ago

Last modified 7 years ago

#42096 new defect (bug)

`WP_Term_Query` sanitizes `slug` parameter incorrectly

Reported by: boonebgorges's profile boonebgorges Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch has-unit-tests
Focuses: Cc:


At save time, slugs are sanitized for MySQL using sanitize_title(). When constructing a query that is intended to match slugs sanitized in this way, we should use sanitize_title_for_query(). See #19292 [19444].

WP_Term_Query improperly uses sanitize_title() in the query context.,498#L494 It has always been thus: [30024], [5525]. It should be fixed. Let's get a unit test that describes the bug (see #19292 for sample payload).

Attachments (2)

42096.patch (1.2 KB) - added by tomllobet 7 years ago.
patch with sanitize_title_for_query
42096_tests.patch (2.1 KB) - added by petertoi 7 years ago.
Tests against WP_Term_Query and WP_Query

Download all attachments as: .zip

Change History (7)

7 years ago

patch with sanitize_title_for_query

#2 @tomllobet
7 years ago

  • Keywords has-patch added; needs-patch removed

We were working on this patch together during a contrib2core meetup with: @petertoi, @pbearne, @benmoody & @jeremyescott. Tests will follow.

This ticket was mentioned in Slack in #core by petertoi. View the logs.

7 years ago

7 years ago

Tests against WP_Term_Query and WP_Query

#4 @petertoi
7 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed

#5 @pbearne
7 years ago

FYI: The recording of the Meetup where we created the patch

Last edited 7 years ago by pbearne (previous) (diff)
Note: See TracTickets for help on using tickets.