Skip to content

Commit 27aa1ec

Browse files
committed
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 `int`s. Casting the strings to integers avoids PHP notices due to incorrect argument types. Props hilayt24. Fixes #54186 git-svn-id: https://develop.svn.wordpress.org/trunk@54126 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4b34765 commit 27aa1ec

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/wp-includes/post.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4945,9 +4945,9 @@ function wp_resolve_post_date( $post_date = '', $post_date_gmt = '' ) {
49454945
}
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 );
49534953

0 commit comments

Comments
 (0)