From 27aa1ec4c6e8b3552787b4f8e91f3e83a7def272 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sun, 11 Sep 2022 21:56:42 +0000 Subject: [PATCH] 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 --- src/wp-includes/post.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 6a0af16a8b..ad271c2ab8 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -4945,9 +4945,9 @@ function wp_resolve_post_date( $post_date = '', $post_date_gmt = '' ) { } // Validate the date. - $month = substr( $post_date, 5, 2 ); - $day = substr( $post_date, 8, 2 ); - $year = substr( $post_date, 0, 4 ); + $month = (int) substr( $post_date, 5, 2 ); + $day = (int) substr( $post_date, 8, 2 ); + $year = (int) substr( $post_date, 0, 4 ); $valid_date = wp_checkdate( $month, $day, $year, $post_date );