Opened 6 days ago
Closed 5 days ago
#64844 closed defect (bug) (fixed)
REST API: Support nested _fields in revisions controller
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | REST API | Keywords: | has-patch |
| Focuses: | Cc: |
Description
WP_REST_Revisions_Controller::prepare_item_for_response() uses in_array() for content, title, excerpt, and guid fields, which doesn't support nested _fields syntax (e.g. _fields=content.raw).
PR: https://github.com/WordPress/wordpress-develop/pull/11230
Change History (3)
This ticket was mentioned in PR #11230 on WordPress/wordpress-develop by @ellatrix.
6 days ago
#1
@ellatrix commented on PR #11230:
5 days ago
#2
Thanks for the review! I'm going to leave it as-is since we're close to Beta 5.
Note: See
TracTickets for help on using
tickets.
https://core.trac.wordpress.org/ticket/64844
Use
rest_is_field_included()instead ofin_array()forcontent,title,excerpt, andguidfields inWP_REST_Revisions_Controller. This lets clients request specific sub-fields (e.g._fields=content.raw) and skip expensivethe_contentrendering.The REST API `_fields` documentation states that nested fields are supported using dot notation. However, the revisions controller uses
in_array()which doesn't match nested keys likecontent.raw.Several other controllers already use
rest_is_field_included()forraw/renderedsub-fields:title.raw,title.rendered,content.raw,content.renderedcontent.raw,title.raw,title.renderedtitle.raw,title.renderedtitle.raw,title.rendered{field}.raw,{field}.renderedRelated Gutenberg PR: https://github.com/WordPress/gutenberg/pull/76347