[wp-trac] [WordPress Trac] #35820: WP_Query(array( 'p' => 0)) will return posts
WordPress Trac
noreply at wordpress.org
Fri Feb 12 21:54:37 UTC 2016
#35820: WP_Query(array( 'p' => 0)) will return posts
----------------------------+-----------------------------
Reporter: ChiefAlchemist | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Query | Version: 4.4.2
Severity: normal | Resolution:
Keywords: | Focuses:
----------------------------+-----------------------------
Changes (by boonebgorges):
* component: Database => Query
* milestone: Awaiting Review => Future Release
Comment:
I agree that it's counterintuitive, and that, in theory, `'p' => 0` should
return no results.
However, it's likely that such a change would introduce backward
compatibility concerns. See #35090 and [36381] for a similar issue, where
it was quickly discovered that people were passing `0` to disable the
parameter, rather than to match `0` as a value.
In order to consider a change like this (which applies equally to
`page_id`, `year`, `monthnum`, `day`, `w`, `paged`, and maybe others), we
need a couple things:
1. Unit tests describing the changed behavior
2. A review of the plugin repo to see the circumstances in which people
are passing `'p' => 0` to `WP_Query`. If it's widely used as a way to
disable the `p` check, then we probably can't change it. (This is a good
task for anyone wanting to help with the ticket.)
3. Assuming it's not being widely exploited, we should drop it in at the
very beginning of a dev cycle, with some related publicity, so we have
time to see what breaks.
[attachment:35820.diff] is what the patch would look like.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35820#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list