WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/24/2014 07:56:54 PM (6 years ago)
Author:
wonderboymusic
Message:

When using meta_query in a WP_Query, passing NOT EXISTS or '' to compare should not require value to be set. The resulting SQL should then produce the appropriate OR clause for existence of non-existence after passing the query to the $key_only_queries stack internally.

Adds unit tests.

Props chrisguitarguy, for the original patch.
Fixes #23268.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/meta.php

    r27562 r27689  
    754754        if ( 'OR' == $this->relation ) {
    755755            foreach ( $this->queries as $k => $q ) {
    756                 if ( ! array_key_exists( 'value', $q ) && ! empty( $q['key'] ) )
     756                if ( ( empty( $q['compare'] ) || 'NOT EXISTS' != $q['compare'] ) && ! array_key_exists( 'value', $q ) && ! empty( $q['key'] ) )
    757757                    $key_only_queries[$k] = $q;
    758758                else
Note: See TracChangeset for help on using the changeset viewer.