#51677 closed defect (bug) (wontfix)
Limit param not consistent between object query classes.
Reported by: | keraweb | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Query | Keywords: | |
Focuses: | Cc: |
Description
When querying without limit for posts (posts_per_page
param) you pass -1
as the limit parameter.
If you want to do the same for terms (number
param) you need to pass 0
.
These two options are apparently not both valid in both cases.
For consistency I'd say both -1
and 0
should be valid as a "no limit" query parameter in all cases.
Or at least the WP_Term_Query
class should also accept -1
as the limiting param.
Change History (5)
This ticket was mentioned in Slack in #core by noisysocks. View the logs.
4 years ago
#2
@
4 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
#3
@
4 years ago
Hi @markparnell
And what about just allowing -1
as the number
param for terms? This shouldn't break backwards compatibility right?
#4
follow-up:
↓ 5
@
4 years ago
@keraweb unfortunately it could. Right now WP_Term_Query
runs absint()
over the passed value, so -1
becomes 1
. If anyone is (incorrectly) passing a negative value right now, changing it to return all results for -1
would alter the results they get.
You can see more detail on the discussion we had around this issue in the Slack archive
#5
in reply to:
↑ 4
@
4 years ago
Replying to markparnell:
If anyone is (incorrectly) passing a negative value right now, changing it to return all results for
-1
would alter the results they get.
Are you saying WordPress even considers incorrect function usages for backwards compatibility?
Read through the Slack discussion and I have to say though I'm very much pro backwards compatibility, that seems a bit overdone to me..
Hi @keraweb, thanks for the report. We had a look and it's even stranger than it seems on the surface! Unfortunately with the way that the different values are treated right now, to change either query could potentially causing backwards compatibility issues with code that is relying on the existing behaviour. So as much as this is weird and frustrating it's not something that we can safely do anything about at this time.