[wp-trac] [WordPress Trac] #49252: REST API response not valid for null on 5.3.2

WordPress Trac noreply at wordpress.org
Mon Feb 24 15:43:48 UTC 2020


#49252: REST API response not valid for null on 5.3.2
-------------------------------------+------------------------------
 Reporter:  jankadlec                |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  REST API                 |     Version:  5.3
 Severity:  normal                   |  Resolution:
 Keywords:  reporter-feedback close  |     Focuses:
-------------------------------------+------------------------------

Comment (by jankadlec):

 Hi @TimothyBlynJacobs

 >> We are taking null to mean the absence of a response here
 yes, that's the problem. In PHP there is lot of overloading of null value,
 this is really not something that anyone asked for. It's mixing meanings
 of statuses and interpreting data values in general context, where you do
 not have enough information to extrapolate that.

 In fact all what is needed is covered in underlying marshaling functions
 in WordPress, and it's done correctly. Why are you altering that from
 higher level please?

 the code should be
 {{{
 if ( 204 === $code ) {
     return null;
   }
 }}}

 as RFC says that there MUST NOT be a content for 204.

 Any additional "guesses" on $result beeing 0, [], null, [null, null, null]
 etc. are unwanted sideeffects IMHO


 I'm interfacing Wordpress API for first time, but if you want someone to
 use Wordpress API, you need to manage it in more backward compatible
 way...

 What about 205 http status? Shall I include it in my conditions as this
 will probably happen for it too?

 Best Regards

 Jan

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


More information about the wp-trac mailing list