REST API: Don't assume all item schemas have properties.

All schema types, not just objects, are permitted as the base type of a resource. A future patch could add validation support for those types, but this fix only prevents a PHP warning from being issued.

Props dhavalkasvala, johnwatkins0, birgire.
Fixes #48785.

Built from https://develop.svn.wordpress.org/trunk@47328


git-svn-id: http://core.svn.wordpress.org/trunk@47122 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
TimothyBlynJacobs 2020-02-20 16:58:06 +00:00
parent a5cfb704bd
commit 5031baa32b
2 changed files with 5 additions and 3 deletions

View File

@ -344,8 +344,10 @@ abstract class WP_REST_Controller {
$schema = $this->get_item_schema();
foreach ( $schema['properties'] as &$property ) {
unset( $property['arg_options'] );
if ( ! empty( $schema['properties'] ) ) {
foreach ( $schema['properties'] as &$property ) {
unset( $property['arg_options'] );
}
}
return $schema;

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.4-beta2-47327';
$wp_version = '5.4-beta2-47328';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.