WordPress.org

Make WordPress Core

Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#23294 closed defect (bug) (duplicate)

Using "OR" in 'meta_query' negates the "NOT EXISTS" compare.

Reported by: hereswhatidid Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:

Description

When using the "NOT EXISTS" compare within 'meta_query' to look for undefined custom fields if I also add in a secondary 'OR' query, the entire query behaves as if I was just checking for "EXISTS". The following code:

'meta_query' => array(
  'relation' => 'OR',
  array(
    'key' => 'status',
    'compare' => 'NOT EXISTS',
  ),
  array(
    'key' => 'status',
    'value' => 'new',
    'compare' => '=',
  ),
);

will return any post that has a value set for the "status" custom field.

Change History (2)

comment:1 hereswhatidid15 months ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #23268.

comment:2 helen15 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.