REST API: Allow posts to be published with a publication date of midnight 1970-01-01.

Explicitly checks date parsing return values for `false`, so that `0` (the value returned for the UNIX epoch of `1970-01-01 00:00:00`) is correctly treated as a valid timestamp.

It should be valid to create a post dated to any point in history.

Props emmanuel78, sabernhardt, siliconforks, drjosh07, antpb, TimothyBlynJacobs.
Fixes #60184.



Built from https://develop.svn.wordpress.org/trunk@59040


git-svn-id: http://core.svn.wordpress.org/trunk@58436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
K. Adam White 2024-09-17 23:24:12 +00:00
parent 723d01e3e1
commit 24a4ba8885
2 changed files with 6 additions and 3 deletions

View File

@ -1304,6 +1304,9 @@ function rest_get_avatar_sizes() {
/**
* Parses an RFC3339 time into a Unix timestamp.
*
* Explicitly check for `false` to detect failure, as zero is a valid return
* value on success.
*
* @since 4.4.0
*
* @param string $date RFC3339 timestamp.
@ -1369,7 +1372,7 @@ function rest_get_date_with_gmt( $date, $is_utc = false ) {
$date = rest_parse_date( $date );
if ( empty( $date ) ) {
if ( false === $date ) {
return null;
}
@ -2259,7 +2262,7 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) {
break;
case 'date-time':
if ( ! rest_parse_date( $value ) ) {
if ( false === rest_parse_date( $value ) ) {
return new WP_Error( 'rest_invalid_date', __( 'Invalid date.' ) );
}
break;

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-59039';
$wp_version = '6.7-alpha-59040';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.