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.



git-svn-id: https://develop.svn.wordpress.org/trunk@25239 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2013-09-04 18:50:04 +00:00
parent 0d0b17b617
commit 24bf60bb4f
2 changed files with 22 additions and 1 deletions

View File

@@ -369,4 +369,23 @@ class Tests_Query_Results extends WP_UnitTestCase {
'child-two',
), wp_list_pluck( $posts, 'post_title' ) );
}
function test_exlude_from_search_empty() {
global $wp_post_types;
foreach ( array_keys( $wp_post_types ) as $slug )
$wp_post_types[$slug]->exclude_from_search = true;
$posts = $this->q->query( array( 'post_type' => 'any' ) );
$this->assertEmpty( $posts );
$this->assertRegExp( '#AND 1=0#', $this->q->request );
foreach ( array_keys( $wp_post_types ) as $slug )
$wp_post_types[$slug]->exclude_from_search = false;
$posts2 = $this->q->query( array( 'post_type' => 'any' ) );
$this->assertNotEmpty( $posts2 );
$this->assertNotRegExp( '#AND 1=0#', $this->q->request );
}
}