From 5031baa32bbf99c84d7e8fd0fd5c766ed4ce6afe Mon Sep 17 00:00:00 2001 From: TimothyBlynJacobs Date: Thu, 20 Feb 2020 16:58:06 +0000 Subject: [PATCH] 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 --- wp-includes/rest-api/endpoints/class-wp-rest-controller.php | 6 ++++-- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-controller.php index dd40d93d2b..b32f012542 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-controller.php @@ -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; diff --git a/wp-includes/version.php b/wp-includes/version.php index 6b432ebdde..80220394cd 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.