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.


git-svn-id: https://develop.svn.wordpress.org/trunk@47362 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
K. Adam White
2020-02-25 15:32:27 +00:00
parent b5190458fe
commit 4e0062e5be
3 changed files with 18 additions and 0 deletions

View File

@@ -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;
}