Make WordPress Core


Ignore:
Timestamp:
02/20/2020 04:56:17 PM (4 years ago)
Author:
TimothyBlynJacobs
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php

    r47122 r47328  
    345345        $schema = $this->get_item_schema();
    346346
    347         foreach ( $schema['properties'] as &$property ) {
    348             unset( $property['arg_options'] );
     347        if ( ! empty( $schema['properties'] ) ) {
     348            foreach ( $schema['properties'] as &$property ) {
     349                unset( $property['arg_options'] );
     350            }
    349351        }
    350352
Note: See TracChangeset for help on using the changeset viewer.