Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ PHP NEWS
argument handling now raises TypeError instead of Error. (Weilin Du)
. IntlBreakIterator::getLocale() now raises ValueError for invalid locale
types. (Weilin Du)
. Fixed MessageFormatter::parse() and parseMessage() returning PHP_INT_MIN
as float rather than int on 64-bit platforms. (Weilin Du)

- JSON:
. Enriched JSON last error / exception message with error location.
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ PHP 8.6 UPGRADE NOTES
. IntlBreakIterator::getLocale() now raises a ValueError when the type is
neither Locale::ACTUAL_LOCALE nor Locale::VALID_LOCALE instead of
returning false.
. MessageFormatter::parse() and parseMessage() now return PHP_INT_MIN as
int, rather than float, on 64-bit platforms when parsing integer values.

- PCNTL:
. pcntl_alarm() now raises a ValueError if the seconds argument is
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/msgformat/msgformat_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ U_CFUNC void umsg_parse_helper(UMessageFormat *fmt, int *count, zval **args, UCh

case Formattable::kInt64:
aInt64 = fargs[i].getInt64();
if(aInt64 > ZEND_LONG_MAX || aInt64 < -ZEND_LONG_MAX) {
if(aInt64 > ZEND_LONG_MAX || aInt64 < ZEND_LONG_MIN) {
ZVAL_DOUBLE(&(*args)[i], (double)aInt64);
} else {
ZVAL_LONG(&(*args)[i], (zend_long)aInt64);
Expand Down
26 changes: 26 additions & 0 deletions ext/intl/tests/msgfmt_parse_int64_min_64.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
MessageFormatter::parse() with PHP_INT_MIN on 64-bit platform
--EXTENSIONS--
intl
--SKIPIF--
<?php if (PHP_INT_SIZE != 8) die("skip 64-bit only"); ?>
--FILE--
<?php

$fmt = new MessageFormatter('en_US', '{0,number,integer}');
$parsed = $fmt->parse('-9,223,372,036,854,775,808');
var_dump($parsed);

$parsed = MessageFormatter::parseMessage('en_US', '{0,number,integer}', '-9,223,372,036,854,775,808');
var_dump($parsed);

?>
--EXPECT--
array(1) {
[0]=>
int(-9223372036854775808)
}
array(1) {
[0]=>
int(-9223372036854775808)
}
Loading