#50700 closed defect (bug) (fixed)
REST API: Small optimizations to filtering by context
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | 5.5 |
Component: | REST API | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
As previously discussed in Slack, the attached patch proposes some minor optimizations to rest_filter_response_by_context()
and adds a few tests.
In the patch:
- Avoid recalculating the schema
type
with each iteration of the loop.
- If the schema type is an array including both
array
andobject
, attempt to use the best type for the given response data (currently, the data is always be treated asarray
). Includes a test for this case.
- If the type is
array
and the context ofitems
doesn't match, return an empty array and break out of the loop since each item will be checked against the same schema anyway. Includes a test for this case.
Attachments (1)
Change History (5)
This ticket was mentioned in PR #424 on WordPress/wordpress-develop by dlh01.
3 years ago
#2
- Keywords has-unit-tests added
The attached patch proposes some minor optimizations to rest_filter_response_by_context() and adds a few tests..
Trac ticket: https://core.trac.wordpress.org/ticket/50700
#3
@
3 years ago
- Owner set to TimothyBlynJacobs
- Resolution set to fixed
- Status changed from new to closed
In 48555:
dream-encode commented on PR #424:
3 years ago
#4
Merged into WP Core in https://core.trac.wordpress.org/changeset/48555
Note: See
TracTickets for help on using
tickets.
Thanks for this @dlh! This looks right to me. Can you make this a PR so we can get the full test suite to run?