Tax query forces multiple post type treatment due to array check
|Reported by:||nacin||Owned by:||nacin|
In WP_Query, if you have more than one post type in the query, things get much more complicated, because we can't do generic permissions checks in SQL. Prime example would be read_private_posts. I spotted the bug here because I was not able to see private posts by others in a widget produced with the help of a tax query.
Sometimes what happens instead is $post_type is set to either 'multiple_post_type' or 'any' to deliberately throw off cap checks. These should probably be more special and handled in a better way. That is not the bug I am reporting, though.
When is_tax, we loop through the taxonomies to extract the associated post types, rather than specifying 'any' as we had done prior to #21290. $post_type ends up always being an array here, even if there's only one post type found.
Later on, when deciding if we are dealing with multiple post types, we only check is_array() — an array with one element is not properly treated as a single post type query.
We should adjust both cases. Let's let $post_type be scalar if that's all we found in the is_tax branch, but let's also treat an array( $one_post_type ) as exactly one post type.