[wp-trac] [WordPress Trac] #57683: Improve performance of mysql2date
WordPress Trac
noreply at wordpress.org
Thu Nov 6 23:36:08 UTC 2025
#57683: Improve performance of mysql2date
------------------------------+---------------------------
Reporter: spacedmonkey | Owner: spacedmonkey
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.3
Component: Date/Time | Version: 0.71
Severity: normal | Resolution: fixed
Keywords: has-patch commit | Focuses: performance
------------------------------+---------------------------
Comment (by johnjamesjacoby):
In [changeset:"61172" 61172]:
{{{
#!CommitTicketReference repository="" revision="61172"
Date/Time: Prevent a PHP exception when inserting posts with a partially
malformed `post_date`.
This commit updates `wp_resolve_post_date()` to use a regular expression
for parsing the date string into year, month, and day matches. This
approach handles missing leading zeros more reliably than `substr()` while
remaining performant (see #57683).
It also adds checks and type-casting to `wp_checkdate()` variables before
passing them into PHP's `checkdate()` function to avoid the potential for
a `TypeError` in PHP 8 and newer (see #54186).
Lastly, it includes 2 new unit tests (with data providers) to cover an
array of valid and invalid date formats (YYYY-MM-DD, YYYY-MM-DD HH:MM:SS,
ISO 8601, RSS, leap years, malformed inputs, etc...)
Props alordiel, desrosj, johnbillion, johnjamesjacoby, johnregan3,
modius5150, nacin, pbearne.
Fixes #26798.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57683#comment:37>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list