WordPress.org

Make WordPress Core

Ticket #10332: 10332.2.diff

File 10332.2.diff, 642 bytes (added by nacin, 5 years ago)

Also tries to take into account 32 bit systems. If 1969 does not compute on the system, then it's a PHP < 5.1 issue. Otherwise, if date('U',$t) doesn't match $t, we're looking at a date outside the 32 bit integer limit. (Or a timezone issue? I think we're good there.) Proof of concept and could use some unit tests.

  • wp-includes/functions.php

     
    8585function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { 
    8686        global $wp_locale; 
    8787        $i = $unixtimestamp; 
    88         // Sanity check for PHP 5.1.0- 
    89         if ( false === $i || intval($i) < 0 ) { 
     88        // Sanity check for PHP 5.1.0- and for 32-bit systems. 
     89        if ( false === $i || ( intval($i) < 0 && ( -1 === strtotime( '1969-01-01' ) || $i != date( 'U', $i ) ) ) ) { 
    9090                if ( ! $gmt ) 
    9191                        $i = current_time( 'timestamp' ); 
    9292                else