Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#54186 closed defect (bug) (fixed)

Cast string to int in `wp_checkdate`

Reported by: swissspidy's profile swissspidy Owned by: swissspidy's profile swissspidy
Milestone: 6.1 Priority: normal
Severity: normal Version:
Component: Date/Time Keywords: has-patch
Focuses: Cc:

Description

I am currently getting some PHP warnings when running integration tests against core:

PHP Warning: checkdate() expects parameter 1 to be int, string given in /tmp/wordpress/wp-includes/functions.php on line 6903

As it turns out, 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.

To avoid these warnings, the input arguments should be cast to integers.

Attachments (1)

54186.patch (517 bytes) - added by hilayt24 3 years ago.
Explicitly converted the strings to the integer

Download all attachments as: .zip

Change History (4)

@hilayt24
3 years ago

Explicitly converted the strings to the integer

#1 @hilayt24
3 years ago

  • Keywords has-patch added; needs-patch good-first-bug removed

#2 @swissspidy
2 years ago

  • Owner set to swissspidy
  • Resolution set to fixed
  • Status changed from new to closed

In 54126:

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

#3 @swissspidy
2 years ago

  • Milestone changed from Awaiting Review to 6.1
Note: See TracTickets for help on using tickets.