REST API: Remove specific multi-type schema handling from the themes controller.

Multi-type schema handling was improved in [48306]. In particular, it now allows for sanitizing a multi-typed value that wouldn't validate. Removing this handling will make 3rd party registered theme features more robust.

Fixes #50562.


git-svn-id: https://develop.svn.wordpress.org/trunk@48308 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Timothy Jacobs 2020-07-05 01:04:30 +00:00
parent 798cd1e20b
commit 8082c60b5f

View File

@ -236,18 +236,8 @@ class WP_REST_Themes_Controller extends WP_REST_Controller {
return true;
}
if ( is_array( $support ) ) {
if ( ! $args['variadic'] ) {
$support = $support[0];
}
// Multi-type theme-support schema definitions always list boolean first.
if ( is_array( $schema['type'] ) && 'boolean' === $schema['type'][0] ) {
// Pass the non-boolean type through to the sanitizer, which cannot itself
// determine the intended type if the value is invalid (for example if an
// object includes non-safelisted properties). See #50300.
$schema['type'] = $schema['type'][1];
}
if ( is_array( $support ) && ! $args['variadic'] ) {
$support = $support[0];
}
return rest_sanitize_value_from_schema( $support, $schema );