Make WordPress Core


Ignore:
Timestamp:
09/11/2022 09:56:42 PM (2 years ago)
Author:
swissspidy
Message:

Date/Time: Cast extracted strings to integers in wp_resolve_post_date().

wp_resolve_post_date() extracts year/month/day from a post date (which is a string) and passes it to wp_checkdate (and from there to checkdate()), which requires ints.

Casting the strings to integers avoids PHP notices due to incorrect argument types.

Props hilayt24.
Fixes #54186

File:
1 edited

Legend:

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

    r54085 r54126  
    49464946
    49474947    // Validate the date.
    4948     $month = substr( $post_date, 5, 2 );
    4949     $day   = substr( $post_date, 8, 2 );
    4950     $year  = substr( $post_date, 0, 4 );
     4948    $month = (int) substr( $post_date, 5, 2 );
     4949    $day   = (int) substr( $post_date, 8, 2 );
     4950    $year  = (int) substr( $post_date, 0, 4 );
    49514951
    49524952    $valid_date = wp_checkdate( $month, $day, $year, $post_date );
Note: See TracChangeset for help on using the changeset viewer.