Repository navigation
Fixed int32 underflow on DateTime::createFromTimestamp - #12775
Conversation
9c07b42 to
548fe60
Compare
|
|
2f57d4e to
491db8b
Compare
|
Ping @derickr |
|
The ASAN tests still seem to fail... I did try restarting it, but it's the same result. They need to get fixed before we can merge this. |
…F_ZEND_LONG/ZEND_DOUBLE_FITS_LONG
491db8b to
26d3153
Compare
|
@derickr it's fixed now. I have rebased against master and for some reason I was using SIZEOF_TIMELIB_LONG which doesn't exist. About TIMELIB_LONG vs. ZEND_LONG can this ever differ? I have seen some logic to force 32bit in it or would it be better to simply fail compile if zend long != timelib long? |
derickr
left a comment
There was a problem hiding this comment.
This LGTM, but I would want to have a second opinion. @iluuu1994 @kocsismate ?
iluuu1994
left a comment
There was a problem hiding this comment.
The code itself looks good to me. Thanks @marc-mabe!
| "Seconds must be a finite number between " TIMELIB_LONG_FMT " and " TIMELIB_LONG_FMT ", %g given", | ||
| TIMELIB_LONG_MIN, | ||
| TIMELIB_LONG_MAX, | ||
| sec_dval |
There was a problem hiding this comment.
Not printing usec would be confusing here.
There was a problem hiding this comment.
Mh to be precise the timestamp must be between TIMELIB_LONG_MIN.0 and TIMELIB_LONG_MAX.999999.
Should this be included in the message as well as currently it's about the seconds part only.
There was a problem hiding this comment.
I have updated the message to Timestamp must be a finite number between {TIMELIB_LONG_MIN} and {TIMELIB_LONG_MAX}.999999, {ARGUMENT} given
| zend_throw_error( | ||
| date_ce_date_range_error, | ||
| "Seconds must be a finite number between " TIMELIB_LONG_FMT " and " TIMELIB_LONG_FMT ", %g given", | ||
| "Timestamp must be a finite number between " TIMELIB_LONG_FMT " and " TIMELIB_LONG_FMT ".999999, %g given", |
There was a problem hiding this comment.
This should probably use our default zend_argument_error format:
Argument #1 ($timestamp) must be a finite number between ...
There was a problem hiding this comment.
I thought it's better matching the DateRangeError event though the documentation needs to be updated. https://www.php.net/manual/en/class.daterangeerror.php
What do you think?
There was a problem hiding this comment.
Now I got it. This makes sense 👍
-> Updated the PR accordingly
|
@derickr @iluuu1994 can this PR be merged now? |
This fixes an integer underflow on passing
PHP_INT_MIN - 0.XtoDateTime[Immutable]::createFromTimestamp().This is due to the fact that the fractional part is handled separately ...
PS:
PHP_INT_MAX + 0.Xdoes not have this issueSimilar to
ZEND_DOUBLE_FITS_LONGthis is introducingPHP_DATE_DOUBLE_FITS_LONGbased onTIMELIB_LONG_MIN/MAX/cc @iluuu1994 @derickr