[wp-trac] [WordPress Trac] #45099: REST API: Render only additional fields specific to request when _fields= is used

WordPress Trac noreply at wordpress.org
Wed Oct 17 01:24:37 UTC 2018


#45099: REST API: Render only additional fields specific to request when _fields=
is used
--------------------------+--------------------------------------
 Reporter:  dlh           |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  5.0
Component:  REST API      |    Version:  4.9.8
 Severity:  normal        |   Keywords:  has-patch has-unit-tests
  Focuses:                |
--------------------------+--------------------------------------
 Follow-up to #43874.

 #43874 caused only requested `_fields` to be processed within the core
 REST controllers' `prepare_item_for_response()`.

 However, callbacks added with `register_rest_field()` still fire during
 `WP_REST_Controller::add_additional_fields_to_object()` regardless of the
 requested `_fields`.

 The attached patch would add a check for the requested fields to
 `add_additional_fields_to_object()` before firing the callbacks.

 As suggested in Slack, I'm setting the milestone for this ticket to 5.0:
 https://wordpress.slack.com/archives/C02RQC26G/p1539604416000100.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45099>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list