[wp-trac] [WordPress Trac] #30681: Using a value in a meta_query (in WP_Query) combined with EXISTS OR NOT EXISTS breaks query
WordPress Trac
noreply at wordpress.org
Thu Dec 11 22:05:23 UTC 2014
#30681: Using a value in a meta_query (in WP_Query) combined with EXISTS OR NOT
EXISTS breaks query
--------------------------+--------------------
Reporter: barrykooij | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.1
Component: General | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+--------------------
Changes (by barrykooij):
* keywords: has-patch needs-unit-tests =>
* component: Query => General
Comment:
The reason it breaks:
In the switch statement on $meta_compare the default case will be used for
EXISTS and NOT EXISTS. Therefor this code will run on an empty string
{{{
$where = $wpdb->prepare( '%s', $meta_value );
}}}
resulting in '' ( a string with just 2 quotes). That string with just 2
quotes will pass this check
{{{
if ( $where ) {
}}}
and therefor attach the complete where statement to the SQL chunks.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30681#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list