[wp-trac] [WordPress Trac] #53372: Loose type check against dates in rest_validate_value_from_schema causes invalidation for valid timestamp
WordPress Trac
noreply at wordpress.org
Wed Jun 9 18:51:42 UTC 2021
#53372: Loose type check against dates in rest_validate_value_from_schema causes
invalidation for valid timestamp
---------------------------+-----------------------------
Reporter: jonmcpartland | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: trunk
Severity: minor | Keywords:
Focuses: rest-api |
---------------------------+-----------------------------
When validating dates, `rest_validate_value_from_schema` assumes a falsy
return value from `rest_parse_date` always means that the date is invalid
(see [wp-includes/rest-api.php at L2138](https://github.com/WordPress
/wordpress-develop/blob/5.7/src/wp-includes/rest-api.php#L2138). This is
correct in all but one case (to my knowledge).
A perfectly valid date would be `1970-01-01 00:00:00`. However, since that
date would produce a return value from `rest_parse_date` of `0`,
`rest_validate_value_from_schema` assumes it is invalid.
Since `rest_parse_date` returns the return value of `strtotime`, checking
that the return value is `false` — rather than falsy — would be sufficient
to resolve.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53372>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list