Make WordPress Core


Ignore:
Timestamp:
09/09/2016 07:36:22 PM (7 years ago)
Author:
boonebgorges
Message:

Query: Avoid PHP notice in get_queried_object() when query contains NOT EXISTS tax query.

Props johnjamesjacoby.
See #37962.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query.php

    r36484 r38585  
    119119    }
    120120
     121    /**
     122     * @ticket 37962
     123     */
     124    public function test_get_queried_object_should_return_null_for_not_exists_tax_query() {
     125        register_taxonomy( 'wptests_tax', 'post' );
     126
     127        $q = new WP_Query( array(
     128            'tax_query' => array(
     129                array(
     130                    'taxonomy' => 'wptests_tax',
     131                    'operator' => 'NOT EXISTS',
     132                ),
     133            ),
     134        ) );
     135
     136        $queried_object = $q->get_queried_object();
     137        $this->assertNull( $queried_object );
     138    }
     139
    121140    public function test_orderby_space_separated() {
    122141        global $wpdb;
Note: See TracChangeset for help on using the changeset viewer.