[wp-trac] [WordPress Trac] #43874: REST API: Only render fields specific to request when _fields= is used

WordPress Trac noreply at wordpress.org
Mon Apr 30 13:50:53 UTC 2018


#43874: REST API: Only render fields specific to request when _fields= is used
---------------------------------------------+-----------------------------
 Reporter:  danielbachhuber                  |       Owner:  (none)
     Type:  defect (bug)                     |      Status:  new
 Priority:  normal                           |   Milestone:  4.9.7
Component:  REST API                         |     Version:
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  rest-api,
                                             |  performance
---------------------------------------------+-----------------------------
Changes (by danielbachhuber):

 * keywords:   => has-patch has-unit-tests commit
 * milestone:  4.9.6 => 4.9.7


Comment:

 `43874.1.diff` introduces a
 `WP_REST_Controller::get_fields_for_response()` method that's used in all
 sub-classed controllers except `WP_REST_Settings_Controller`. I've
 included tests for the base method and each impacted subclass.

 When `_fields=[]` is used, this changeset will change the data passed into
 `add_additional_fields_to_object()`. Notably, this includes callbacks
 added via `register_rest_field()`. Because of this, `id` is always
 included in the original response preparation, so it can continue to be a
 lookup value.

 I'd like to land this in trunk so we can consider including this in 4.9.7.
 I don't think it's so pressing that we need to get into 4.9.6.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43874#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list