[wp-trac] [WordPress Trac] #45220: register_rest_field() doesn't work when schema is empty

WordPress Trac noreply at wordpress.org
Mon Nov 19 13:57:21 UTC 2018


#45220: register_rest_field() doesn't work when schema is empty
---------------------------------------------+-----------------------
 Reporter:  Dudo                             |       Owner:  (none)
     Type:  defect (bug)                     |      Status:  new
 Priority:  normal                           |   Milestone:  5.0
Component:  REST API                         |     Version:  5.0
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  rest-api
---------------------------------------------+-----------------------

Comment (by danielbachhuber):

 In [attachment:"45220.2.diff"], any fields registered with
 `register_rest_field()` that have a null schema are included in
 `WP_REST_Controller::get_fields_for_response()`. I think this is a more
 appropriate fix because:

 1. It ensures `get_fields_for_response()` has the expected return values.
 2. It includes `my_custom_int` in the response when the request is
 `?_fields=title,my_custom_int`.

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


More information about the wp-trac mailing list