From ae5fb83507ba64c2a8aeb7b27fe6aa1c9c14d201 Mon Sep 17 00:00:00 2001 From: TimothyBlynJacobs Date: Thu, 27 Aug 2020 02:57:03 +0000 Subject: [PATCH] REST API: Fix multi-type schemas with integer fields. In [48306] support for multi-typed schemas was improved to first detect the data type of the value before applying further validation. The `integer` data type was detected using the new `rest_is_integer` function. This function used logic, however, that assumed that the value had already passed an `is_numeric` check. This meant that if `integer` and `string` were both acceptable types, the value would always be considered an `integer` causing the later accurate type validation to fail. This commit fixes the `rest_is_integer` logic to include an `is_numeric` check. Props rtagliento. Fixes #51146. Built from https://develop.svn.wordpress.org/trunk@48881 git-svn-id: http://core.svn.wordpress.org/trunk@48643 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index 18a90ec2e3..83b724511a 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -1315,7 +1315,7 @@ function rest_is_boolean( $maybe_bool ) { * @return bool True if an integer, otherwise false. */ function rest_is_integer( $maybe_integer ) { - return round( floatval( $maybe_integer ) ) === floatval( $maybe_integer ); + return is_numeric( $maybe_integer ) && round( floatval( $maybe_integer ) ) === floatval( $maybe_integer ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 7a2fe6daca..ccde144164 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-48880'; +$wp_version = '5.6-alpha-48881'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.