[wp-trac] [WordPress Trac] #50300: Multi type on args properties returning invalid error message when not validated
WordPress Trac
noreply at wordpress.org
Sun Jul 5 00:13:51 UTC 2020
#50300: Multi type on args properties returning invalid error message when not
validated
-------------------------------------------------+-------------------------
Reporter: pentatonicfunk | Owner:
| TimothyBlynJacobs
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 5.5
Component: REST API | Version: 5.3
Severity: normal | Resolution: fixed
Keywords: json-schema has-patch has-unit- | Focuses: rest-api
tests |
-------------------------------------------------+-------------------------
Changes (by TimothyBlynJacobs):
* owner: (none) => TimothyBlynJacobs
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"48306" 48306]:
{{{
#!CommitTicketReference repository="" revision="48306"
REST API: Make multi-typed schemas more robust.
A multi-type schema is a schema where the `type` keyword is an array of
possible types instead of a single type. For instance, `[ 'object',
'string' ]` would allow objects or string values.
In [46249] basic support for these schemas was introduced. The validator
would loop over each schema type trying to find a version that matched.
This worked for valid values, but for invalid values it provided unhelpful
error messages. The sanitizer also had its utility restricted.
In this commit, the validators and sanitizers will first determine the
best type of the passed value and then apply the schema with that set
type. In the case that a value could match multiple types, the schema of
the first matching type will be used.
To maintain backward compatibility, if unsupported schema types are used,
the value will always pass validation. A doing it wrong notice is issued
in this case.
Fixes #50300.
Props pentatonicfunk, dlh, TimothyBlynJacobs.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50300#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list