Closed cabrerahector closed 4 years ago
This version of the is_timestamp()
function apparently works as expected according to the user who was nice enough to test it on their environment:
/**
* Checks whether a string is a valid timestamp.
*
* @since 5.2.0
* @param string $string
* @return bool
*/
public static function is_timestamp($string)
{
if (
( is_int($string) || ctype_digit($string) )
&& strtotime(date('Y-m-d H:i:s', $string)) === (int) $string
) {
return true;
}
return false;
}
Describe the bug
An user reported here that WordPress Popular Posts throws the following PHP notice when the Pageviews cache feature is enabled:
I was able to reproduce the issue by executing the
is_timestamp()
function several times in afor
loop. Oddly enough, it didn't happen all the time. Sometimes the function returned a boolean value (as expected), others it triggered said error.Environment: