mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
Query: Check each post-type's capabilities when querying multiple post-types.
When querying multiple post types, check the `read_private_posts` capability for each post type when determining which post statuses to return. This ensures private posts appear in search results and archives for users permitted to read them. Props leogermani, hellofromTonya, jeffpaul, peterwilsoncc. Fixes #48556. git-svn-id: https://develop.svn.wordpress.org/trunk@51276 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -98,6 +98,25 @@ class Tests_Query_InvalidQueries extends WP_UnitTestCase {
|
||||
$this->assertCount( 0, $posts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test WP Query with an invalid post type in a mutiple post type query.
|
||||
*
|
||||
* @ticket 48556
|
||||
*/
|
||||
public function test_unregistered_post_type_wp_query_multiple_post_types() {
|
||||
global $wpdb;
|
||||
|
||||
$query = new WP_Query(
|
||||
array(
|
||||
'post_type' => array( 'unregistered_cpt', 'page' ),
|
||||
)
|
||||
);
|
||||
$posts = $query->get_posts();
|
||||
|
||||
$this->assertContains( "{$wpdb->posts}.post_type = 'unregistered_cpt'", self::$last_posts_request );
|
||||
$this->assertCount( 1, $posts, 'the valid `page` post type should still return one post' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test WP Query with an invalid post type specified in the URL.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user