From 44e1bbef85f554b7e671419bfeb605568b667e60 Mon Sep 17 00:00:00 2001 From: "K. Adam White" Date: Tue, 25 Feb 2020 15:34:07 +0000 Subject: [PATCH] REST API: Correctly infer empty objects passed via query parameters. Permit passing an empty object as the string "?obj=". The type of the passed empty argument is inferred from the registered schema. Props TimothyBlynJacobs, steffanhalv, schlessera, dd32. Fixes #42961. Built from https://develop.svn.wordpress.org/trunk@47362 git-svn-id: http://core.svn.wordpress.org/trunk@47149 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api.php | 4 ++++ wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index 5add20bc60..bdfd8fac42 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -1250,6 +1250,10 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) { } if ( 'object' === $args['type'] ) { + if ( '' === $value ) { + $value = array(); + } + if ( $value instanceof stdClass ) { $value = (array) $value; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 9ec2d6e748..b0d8c9caaa 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.4-beta2-47361'; +$wp_version = '5.4-beta2-47362'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.