[wp-trac] [WordPress Trac] #28099: Empty array passed to WP_Query post__in returns posts
WordPress Trac
noreply at wordpress.org
Thu Aug 10 11:01:14 UTC 2023
#28099: Empty array passed to WP_Query post__in returns posts
-----------------------------+------------------------------
Reporter: danielbachhuber | Owner: wonderboymusic
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-----------------------------+------------------------------
Comment (by pikamander2):
If there's any way to rip off the band-aid and make passing 0 actually
return 0 posts, I think that would be the best way forward.
I haven't looked at the underlying code so I might be getting the details
wrong here but I would think that a way forward to a more sane behavior
would be to:
1. Temporarily throw a deprecation warning in an upcoming release when 0
is passed, instructing the developer to instead use null or -1 or no
parameter if they want posts to be displayed or [0] if they don't and
informing them that a future release will change the behavior.
2. In a release sometime after that, remove the deprecation warning and
make 0 actually return 0 posts.
That approach would still cause some friction but would make for a far
better default behavior and would allow actively maintained plugins/themes
to update their code.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28099#comment:39>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list