[wp-trac] [WordPress Trac] #52956: WP_REST_Request->get_params() doesn't correctly handle boolean false

WordPress Trac noreply at wordpress.org
Sat Apr 24 01:08:35 UTC 2021


#52956: WP_REST_Request->get_params() doesn't correctly handle boolean false
--------------------------+---------------------
 Reporter:  ivankk        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:
Component:  REST API      |     Version:  4.7
 Severity:  normal        |  Resolution:
 Keywords:  close         |     Focuses:
--------------------------+---------------------

Comment (by ivankk):

 @TimothyBlynJacobs what do you think about an update to the documentation?

 https://developer.wordpress.org/rest-api/extending-the-rest-api/schema
 /#type-juggling

   Because the WordPress REST API accepts URL form encoded data both in the
 POST body or as the query portion of the URL, many primtive types perform
 type juggling to convert these string values into their proper native
 types.

   **boolean** Booleans, the integers 0 and 1, or the strings "0", "1",
 "false", and "true". 0 is treated as false and 1 is treated as true.


 Maybe the **Overview** section could be updated to elaborate on what sorts
 of things we could be missing out on if we didn't have a schema in place
 (type coercion / juggling as an example):
   You can implement endpoints without using a schema, but you will be
 missing out on a lot of things. It is up to you to decide what suits you
 best.

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


More information about the wp-trac mailing list