#28099 https://core.trac.wordpress.org/ticket/28099 Passing an empty array to post__in will return have_posts() as true (and all posts will be returned).
If the post__in array is empty, the query should return no results instead of all posts. Currently to get the expected query result, the post__in argument must be checked for emptiness and the first element of the array set to 0 before passing to WP_Query->set().
Read-only archive: https://petitions.classicpress.net/posts/155/fix-wp_query-post__in-issue-with-empty-array-input
Author: Lance Willis
Vote count: 3
@Lance Willis: I took a look at the ticket to which you refer, and it seems to me that the reversion was really a case of the tail wagging the dog. Because some plugin developers were “doing it wrong,” this change caused those plugins to break. But even some of those developers themselves said on that ticket that they could easily modify their code and that this change was a good idea.
So I vote to do this. It would be a breaking change but a sensible one. It seems bizarre that passing an empty array returns all posts!
~ posted by Tim Kaye
The workaround I described above will still work after the issue is fixed. Code that expects the current behavior should not set post__in if the array is empty. These workarounds could be added to the CP2 release notes for devs that want their code to work in CP1, CP2, and WP.
~ posted by Lance Willis