[wp-trac] [WordPress Trac] #52932: Rest Api enum validation does not work correctly WordPress 5.7

WordPress Trac noreply at wordpress.org
Sun Apr 4 19:11:21 UTC 2021


#52932: Rest Api enum validation does not work correctly WordPress 5.7
-------------------------------------------------+-------------------------
 Reporter:  stefanjoebstl                        |       Owner:  yakimun
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  5.7.1
Component:  REST API                             |     Version:  5.7
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests commit      |     Focuses:  rest-api
  fixed-major                                    |
-------------------------------------------------+-------------------------
Changes (by SergeyBiryukov):

 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 In [changeset:"50656" 50656]:
 {{{
 #!CommitTicketReference repository="" revision="50656"
 REST API: Correct `enum` validation for numeric values.

 When validating `enum` values as `integer` or `number`, consider a number
 with a zero fractional part to be equivalent to an integer of the same
 value.

 In `rest_are_values_equal()`, when comparing two values of type `int` or
 `float` (in any combination), first cast both of them to `float` and then
 compare.

 This matches some test cases from the official JSON Schema test suite.

 Follow-up to [50010].

 Props yakimun, stefanjoebstl, TimothyBlynJacobs, rachelbaker.
 Merges [50653] to the 5.7 branch.
 Fixes #52932.
 }}}

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


More information about the wp-trac mailing list