| 614 | * @ticket 29062 |
| 615 | */ |
| 616 | public function test_meta_query_compare_not_exists_with_another_condition_relation_or() { |
| 617 | $posts = $this->factory->post->create_many( 4 ); |
| 618 | update_post_meta( $posts[0], 'color', 'orange' ); |
| 619 | update_post_meta( $posts[1], 'color', 'blue' ); |
| 620 | update_post_meta( $posts[1], 'vegetable', 'onion' ); |
| 621 | update_post_meta( $posts[2], 'vegetable', 'shallot' ); |
| 622 | |
| 623 | $post_3_meta = get_post_meta( $posts[3] ); |
| 624 | foreach ( $post_3_meta as $meta_key => $meta_value ) { |
| 625 | delete_post_meta( $posts[3], $meta_key ); |
| 626 | } |
| 627 | |
| 628 | $query = new WP_Query( array( |
| 629 | 'meta_query' => array( |
| 630 | 'relation' => 'OR', |
| 631 | array( |
| 632 | 'key' => 'vegetable', |
| 633 | 'value' => 'onion', |
| 634 | ), |
| 635 | array( |
| 636 | 'key' => 'color', |
| 637 | 'compare' => 'NOT EXISTS', |
| 638 | ), |
| 639 | ), |
| 640 | 'update_post_meta_cache' => false, |
| 641 | 'update_post_term_cache' => false, |
| 642 | 'fields' => 'ids', |
| 643 | ) ); |
| 644 | |
| 645 | $expected = array( $posts[1], $posts[2], $posts[3] ); |
| 646 | $this->assertEqualSets( $expected, $query->posts ); |
| 647 | } |
| 648 | |
| 649 | /** |