#48266 closed defect (bug) (fixed)
REST API: logic used to filter nested _fields does not account for specifying multiple siblings
Reported by: | kadamwhite | Owned by: | kadamwhite |
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | 5.3 |
Component: | REST API | Keywords: | has-unit-tests has-patch has-dev-note |
Focuses: | rest-api | Cc: |
Description
In #42094 we introduced logic to extend the _fields
query parameter in order to specify that we wanted only one piece of a deeply nested object. While writing the dev note for this feature I discovered a logical error where our logic failed to account for the case where we specify two sibling properties of the same nested object.
For example, given the response object
{ "id": 1, "meta": { "key1": 1, "key2": 2 } }
and the query /wp/v2/posts/1?_fields=meta.key1,meta.key2
, only meta.key2 will be included.
We can fix this by adjusting the manner in which rest_filter_response_fields
sets the $ref[ $next ]
value to account for an existing array at that location.
Attachments (3)
Change History (6)
This ticket was mentioned in Slack in #core-restapi by kadamwhite. View the logs.
5 years ago
#3
@
5 years ago
- Keywords has-dev-note added
Adding has-dev-note
tag to the ticket.
https://make.wordpress.org/core/2019/10/10/filtering-nested-rest-response-_fields-in-wp-5-3/
Correct descriptive comment for test