[wp-trac] [WordPress Trac] #44432: Sometimes, an array is passed to the get_callback provided to register_rest_field() instead of an object

WordPress Trac noreply at wordpress.org
Sun Jul 7 20:20:43 UTC 2019


#44432: Sometimes, an array is passed to the get_callback provided to
register_rest_field() instead of an object
-------------------------------+--------------------------------
 Reporter:  salzano            |       Owner:  TimothyBlynJacobs
     Type:  defect (bug)       |      Status:  assigned
 Priority:  normal             |   Milestone:  Future Release
Component:  REST API           |     Version:  4.7
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+--------------------------------
Changes (by TimothyBlynJacobs):

 * keywords:   => reporter-feedback


Comment:

 I looked at all the usages of `add_additional_fields_to_object` and
 `update_additional_fields_for_object`


 {{{
 Autosaves
 - Add Fields: Passes prepared data as an array.

 Comments
 - Add Fields: Passes prepared data as an array.
 - Update fields: Passes WP_Comment object.

 Post Statuses
 - Add Fields: Passes prepared data as an array.

 Post Types
 - Add Fields: Passes prepared data as an array.

 Posts
 - Add Fields: Passes prepared data as an array.
 - Update fields: Passes WP_Post object.

 Revisions
 - Add Fields: Passes prepared data as an array.

 Search
 - Add Fields: Passes prepared data as an array.

 Taxonomies
 - Add Fields: Passes prepared data as an array.

 Terms
 - Add Fields: Passes prepared data as an array.
 - Update fields: Passes WP_Term object.

 Themes
 - Add Fields: Passes prepared data as an array.

 Users
 - Add Fields: Passes prepared data as an array.
 - Update fields: Passes WP_User object.

 Attachments
 - Update fields: Passes WP_Post object.
 }}}

 As far as I can tell, the REST API always passes an `array` to the
 `get_callback()` and always passes an entity object to the
 `update_callback`.

 > An object will still be passed, sometimes, too.

 Could you clarify when this happens?

 Perhaps this has been fixed in the meantime?

 The documentation certainly could use updating as well.

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


More information about the wp-trac mailing list