Make WordPress Core


Ignore:
Timestamp:
10/31/2016 01:47:36 AM (8 years ago)
Author:
pento
Message:

REST API: Add support for arrays in schema validation and sanitization.

By allowing more fine-grained validation and sanitisation of endpoint args, we can ensure the correct data is being passed to endpoints.

This can easily be extended to support new data types, such as CSV fields or objects.

Props joehoyle, rachelbaker, pento.
Fixes #38531.

File:
1 edited

Legend:

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

    r39021 r39046  
    560560            }
    561561
    562             foreach ( array( 'type', 'format', 'enum' ) as $schema_prop ) {
     562            foreach ( array( 'type', 'format', 'enum', 'items' ) as $schema_prop ) {
    563563                if ( isset( $params[ $schema_prop ] ) ) {
    564564                    $endpoint_args[ $field_id ][ $schema_prop ] = $params[ $schema_prop ];
Note: See TracChangeset for help on using the changeset viewer.