[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:29:05 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:  Query                                   |     Version:  trunk
 Severity:  normal                                  |  Resolution:
 Keywords:  needs-unit-tests has-patch 2nd-opinion  |     Focuses:
----------------------------------------------------+--------------------
Changes (by johnbillion):

 * keywords:   => needs-unit-tests has-patch 2nd-opinion
 * component:  General => Query


Comment:

 Code to reproduce the issue:

 {{{
 new WP_Query( array(
         'meta_query' => array(
                 array(
                         'key'     => 'foo',
                         'value'   => 'bar',
                         'compare' => 'NOT EXISTS',
                 )
         ),
 ) );
 }}}

 I think this would benefit from an explicit switch case for `EXISTS` and
 `NOT EXISTS` which ignores the presence of the meta value argument and
 doesn't populate the `WHERE` clause.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30681#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list