[wp-trac] [WordPress Trac] #56494: REST API: Fix and test rest_default_additional_properties_to_false

WordPress Trac noreply at wordpress.org
Wed Aug 9 15:52:23 UTC 2023


#56494: REST API: Fix and test rest_default_additional_properties_to_false
--------------------------------------+------------------------------
 Reporter:  anna.bansaghi             |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  REST API                  |     Version:  6.0.2
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------------

Comment (by leogermani):

 I landed here because of the Warning when `type` is not defined. If `type`
 is defined inside my `anyOf` criteria, there's no point in having a `type`
 in that level.

 The solution here looks great, and kudos for all the explanation, but I
 wonder if this adds too much overhead and could have impact on
 performance. I was wondering if there's a better way to handle this,
 meaning expecting `additionalProperties` to be `false` if not declared.

 Maybe this check could be done somewhere else, when we actually look for
 this property, instead of having to loop through all the schemas to add
 it.

 For example here [https://github.com/WordPress/wordpress-
 develop/blob/trunk/src/wp-includes/rest-api.php#L2353] we could just set
 it to `false` on the fly if not set.

 Same thing on https://github.com/WordPress/wordpress-
 develop/blob/trunk/src/wp-includes/rest-api.php#L2795 and
 https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes
 /rest-api.php#L3030 - and it seems that this is all that's needed.

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


More information about the wp-trac mailing list