Skip to content

Commit d50ead7

Browse files
authored
Merge pull request #28 from WordPress/avoid-calling-strtotime-with-zero-dates
Avoid calling strtotime with "0000-00-00 00:00:00" arg
2 parents e77132d + 6c4530b commit d50ead7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

wp-includes/sqlite/class-wp-sqlite-translator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,12 @@ private function preprocess_string_literal( $value ) {
15741574
* and stop relying on this MySQL feature,
15751575
*/
15761576
if ( 1 === preg_match( '/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})$/', $value, $matches ) ) {
1577-
if ( false === strtotime( $value ) ) {
1577+
/*
1578+
* Calling strtotime("0000-00-00 00:00:00") in 32-bit environments triggers
1579+
* an "out of integer range" warning – let's avoid that call for the popular
1580+
* case of "zero" dates.
1581+
*/
1582+
if ( $value !== "0000-00-00 00:00:00" && false === strtotime( $value ) ) {
15781583
$value = '0000-00-00 00:00:00';
15791584
}
15801585
}

0 commit comments

Comments
 (0)