[wp-trac] [WordPress Trac] #48819: Filter response by context misses certain schemas

WordPress Trac noreply at wordpress.org
Thu Feb 20 01:39:15 UTC 2020


#48819: Filter response by context misses certain schemas
--------------------------------------+--------------------------------
 Reporter:  TimothyBlynJacobs         |       Owner:  TimothyBlynJacobs
     Type:  defect (bug)              |      Status:  assigned
 Priority:  normal                    |   Milestone:  5.4
Component:  REST API                  |     Version:  4.7
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+--------------------------------

Comment (by TimothyBlynJacobs):

 I've uploaded a revised version of the patch that ''does not'' traverse
 child schemas unless a `context` is set at every level. This means the
 performance impact of traversing the entire object will only occur if the
 author is utilizing that functionality.

 That is, for the following schema.

 {{{#!php
 <?php
 array(
         '$schema'    => 'http://json-schema.org/draft-04/schema#',
         'type'       => 'object',
         'properties' => array(
                 'parent' => array(
                         'type'       => 'object',
                         'context'    => array( 'view', 'edit' ),
                         'properties' => array(
                                 'child' => array(
                                         'type'       => 'object',
                                         'properties' => array(
                                                 'grand'  => array(
                                                         'type'    =>
 'string',
                                                         'context' =>
 array( 'view', 'edit' ),
                                                 ),
                                                 'hidden' => array(
                                                         'type'    =>
 'string',
                                                         'context' =>
 array( 'edit' ),
                                                 ),
                                         ),
                                 ),
                         ),
                 ),
         ),
 )
 }}}

 and the following data

 {{{#!php
 <?php
 array(
         'parent' => array(
                 'child' => array(
                         'grand'  => 'hi',
                         'hidden' => 'there',
                 ),
         ),
 )
 }}}

 In the first patch, the hidden field would be excluded, now it isn't.
 Notice that no `context` is specified for the `child` schema.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48819#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list