Make WordPress Core


Ignore:
Timestamp:
12/14/2014 07:30:40 PM (10 years ago)
Author:
johnbillion
Message:

In WP_Meta_Query, interpret 'value' correctly when used with EXISTS/NOT EXISTS.

As in earlier versions, EXISTS with a value is equivalent to '=', while NOT
EXISTS should always ignore 'value'.

Merges [30846] to the 4.1 branch.

Props barrykooij.
Fixes #30681

Location:
branches/4.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1

  • branches/4.1/src/wp-includes/meta.php

    r30753 r30848  
    14201420                    break;
    14211421
     1422                // EXISTS with a value is interpreted as '='.
     1423                case 'EXISTS' :
     1424                    $meta_compare = '=';
     1425                    $where = $wpdb->prepare( '%s', $meta_value );
     1426                    break;
     1427
     1428                // 'value' is ignored for NOT EXISTS.
     1429                case 'NOT EXISTS' :
     1430                    $where = '';
     1431                    break;
     1432
    14221433                default :
    14231434                    $where = $wpdb->prepare( '%s', $meta_value );
Note: See TracChangeset for help on using the changeset viewer.