mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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. Fixes #52932. Built from https://develop.svn.wordpress.org/trunk@50653 git-svn-id: http://core.svn.wordpress.org/trunk@50265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
907bfe74cd
commit
b6e32b9d4f
@ -1926,6 +1926,12 @@ function rest_are_values_equal( $value1, $value2 ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( is_int( $value1 ) && is_float( $value2 )
|
||||
|| is_float( $value1 ) && is_int( $value2 )
|
||||
) {
|
||||
return (float) $value1 === (float) $value2;
|
||||
}
|
||||
|
||||
return $value1 === $value2;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-alpha-50652';
|
||||
$wp_version = '5.8-alpha-50653';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user