Opened 4 weeks ago
Closed 4 weeks ago
#35935 closed defect (bug) (fixed)
Correctly return zero terms when offset is greater than term count
Reported by: | danielbachhuber | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | has-patch has-unit-tests needs-testing |
Focuses: | Cc: |
Description
Reported in https://github.com/WP-API/WP-API/issues/2309
Attachments (2)
Change History (7)
This ticket was mentioned in Slack in #core by danielbachhuber. View the logs.
4 weeks ago
#2
@boonebgorges
4 weeks ago
- Owner set to boonebgorges
- Status changed from new to reviewing
@boonebgorges
4 weeks ago
#3
@boonebgorges
4 weeks ago
- Keywords needs-testing added
#4
@danielbachhuber
4 weeks ago
Your patch doesn't have glaring issues I can see, and works against the (more limited) tests I wrote for WP-API
#5
@boonebgorges
4 weeks ago
- Resolution set to fixed
- Status changed from reviewing to closed
In 36691:
Note: See
TracTickets for help on using
tickets.
Thanks for the ticket and the patch. I've confirmed the issue.
Your fix doesn't go far enough. Your tests are using very large numbers for 'offset' and 'number', which is masking another bug: get_terms() is not properly trimming the array when (number + offset) > count( $terms ) > number. The fix appears to be to skip the count( $terms ) > $number check, and run all results that make it this far through array_slice(). See 35935.diff. Could you double-check my logic?
This collection of bugs exists since [10416], when the fix for hierarchical limits in get_terms() was introduced.