[wp-trac] [WordPress Trac] #23268: NOT EXISTS meta query with OR releation

WordPress Trac noreply at wordpress.org
Tue Jan 29 22:58:27 UTC 2013


#23268: NOT EXISTS meta query with OR releation
--------------------------+------------------------------
 Reporter:  timfield      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by panbolec):

 It is possible to fool WordPress a little :) by asigning anything to
 'value' of EXISTS/NOT EXISTS subquery. This workaround works (and may be
 even funny :-)

 {{{
                  $query['meta_query'] = array(
                     'relation' => 'OR',
                     array(
                         'key' => 'app_exclude',
                         'compare' => 'NOT EXISTS'
                         'value'   => 'completely'
                     ),
                     array(
                         'key' => 'app_exclude',
                         'compare' => '!=',
                         'value' => '1'
                     ),
                 );
 }}}

 The problem is in meta.php, lines:

 {{{
                 if ( 'OR' == $this->relation ) {
                         foreach ( $this->queries as $k => $q ) {
                                 if ( ! isset( $q['value'] ) && ! empty(
 $q['key'] ) )
                                         $key_only_queries[$k] = $q;
                                 else
                                         $queries[$k] = $q;
                         }
                 } else {
                         $queries = $this->queries;
                 }
 }}}

 Following condition:

 {{{
       if ( ! isset( $q['value'] ) && ! empty( $q['key'] ) )
 }}}

 is the source of the problem.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23268#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list