[wp-trac] [WordPress Trac] #51393: REST API: Inconsistent type for 'media_details' and 'sizes' in attachments controller

WordPress Trac noreply at wordpress.org
Fri Sep 25 00:41:42 UTC 2020


#51393: REST API: Inconsistent type for 'media_details' and 'sizes' in attachments
controller
----------------------------+---------------------
 Reporter:  SergeyBiryukov  |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  5.6
Component:  REST API        |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |     Focuses:
----------------------------+---------------------

Comment (by TimothyBlynJacobs):

 I _think_ this was implemented this way so that when the result is
 `json_encode`d it is encoded as an empty json object, instead of a json
 array. Ie `{}` instead of `[]`.

 Regardless, the correct schema type is an `object`. See
 https://developer.wordpress.org/rest-api/extending-the-rest-api/schema
 /#primitive-types for reference.

 > The tests should probably be updated to check if
 $data['media_details']['sizes'] is not empty before proceeding

 I think this is the correct fix. Changing the data values in the
 controller would be a BC break.

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


More information about the wp-trac mailing list