Make WordPress Core


Ignore:
Timestamp:
09/04/2013 06:50:04 PM (12 years ago)
Author:
wonderboymusic
Message:

Kill the query in the following edge case: post_type => 'any' but exclude_from_search => false returns no valid post types. Adds unit tests.

Props mitchoyoshitaka.
Fixes #19198.

File:
1 edited

Legend:

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

    r25002 r25239  
    370370        ), wp_list_pluck( $posts, 'post_title' ) );
    371371    }
     372
     373    function test_exlude_from_search_empty() {
     374        global $wp_post_types;
     375        foreach ( array_keys( $wp_post_types ) as $slug )
     376            $wp_post_types[$slug]->exclude_from_search = true;
     377
     378        $posts = $this->q->query( array( 'post_type' => 'any' ) );
     379
     380        $this->assertEmpty( $posts );
     381        $this->assertRegExp( '#AND 1=0#', $this->q->request );
     382
     383        foreach ( array_keys( $wp_post_types ) as $slug )
     384            $wp_post_types[$slug]->exclude_from_search = false;
     385
     386        $posts2 = $this->q->query( array( 'post_type' => 'any' ) );
     387
     388        $this->assertNotEmpty( $posts2 );
     389        $this->assertNotRegExp( '#AND 1=0#', $this->q->request );
     390    }
    372391}
Note: See TracChangeset for help on using the changeset viewer.