Make WordPress Core


Ignore:
Timestamp:
09/17/2024 11:22:43 PM (21 months ago)
Author:
kadamwhite
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r58933 r59040  
    13051305 * Parses an RFC3339 time into a Unix timestamp.
    13061306 *
     1307 * Explicitly check for `false` to detect failure, as zero is a valid return
     1308 * value on success.
     1309 *
    13071310 * @since 4.4.0
    13081311 *
     
    13701373    $date = rest_parse_date( $date );
    13711374
    1372     if ( empty( $date ) ) {
     1375    if ( false === $date ) {
    13731376        return null;
    13741377    }
     
    22602263
    22612264            case 'date-time':
    2262                 if ( ! rest_parse_date( $value ) ) {
     2265                if ( false === rest_parse_date( $value ) ) {
    22632266                    return new WP_Error( 'rest_invalid_date', __( 'Invalid date.' ) );
    22642267                }
Note: See TracChangeset for help on using the changeset viewer.