[wp-trac] [WordPress Trac] #37276: tax_query with field=name doesn't work if the term contains an apostrophe
WordPress Trac
noreply at wordpress.org
Mon Jul 4 21:24:29 UTC 2016
#37276: tax_query with field=name doesn't work if the term contains an apostrophe
--------------------------+-----------------------------
Reporter: smerriman | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Related to the bug in #27810.
If you create a tax_query with field=name and term containing an
apostrophe, eg:
{{{
new WP_Query(array(
'tax_query'=>array(
array(
'taxonomy'=>'sample-tax',
'field'=>'name',
'terms'=>"Test's"
)
)
));
}}}
the query built in the transform_query function in class-wp-tax-query.php
comes back with:
`... AND wp_terms.name IN ('Test\\\'s')`
and thus generates no results.
It looks like the apostrophe is getting double escaped by both the
`esc_sql` and `sanitize_term_field` calls in @boonebgorges patch.
Stab in the dark - in `wp_insert_term`, `wp_unslash` is called on the name
field after sanitizing it - does the same need to apply here?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37276>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list