From 8082c60b5fd8690b40b559f847ab6116cd089391 Mon Sep 17 00:00:00 2001 From: Timothy Jacobs Date: Sun, 5 Jul 2020 01:04:30 +0000 Subject: [PATCH] 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 --- .../endpoints/class-wp-rest-themes-controller.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php index b5c9a86847..88494a5fa9 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php @@ -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 );