From 45074ee341fc5fae39d041c4ae482824ce55730c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CLamentXU123=E2=80=9D?= <108666168+LamentXU123@users.noreply.github.com> Date: Sat, 23 May 2026 02:24:38 +0800 Subject: [PATCH 1/2] ext/Intl: Return PHP_INT_MIN as int from MessageFormatter::parse() on 64-bit --- NEWS | 2 ++ UPGRADING | 2 ++ ext/intl/msgformat/msgformat_helpers.cpp | 2 +- ext/intl/tests/msgfmt_parse_int64_min_64.phpt | 26 +++++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 ext/intl/tests/msgfmt_parse_int64_min_64.phpt diff --git a/NEWS b/NEWS index e37effff3afe..3bb752f5c8b3 100644 --- a/NEWS +++ b/NEWS @@ -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. diff --git a/UPGRADING b/UPGRADING index a3b22d8c0560..7f805496db74 100644 --- a/UPGRADING +++ b/UPGRADING @@ -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 diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index f504ee50abcb..12e05af57219 100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp @@ -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); diff --git a/ext/intl/tests/msgfmt_parse_int64_min_64.phpt b/ext/intl/tests/msgfmt_parse_int64_min_64.phpt new file mode 100644 index 000000000000..932a888d686b --- /dev/null +++ b/ext/intl/tests/msgfmt_parse_int64_min_64.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug: MessageFormatter::parse() should preserve PHP_INT_MIN as int on 64-bit +--EXTENSIONS-- +intl +--SKIPIF-- + +--FILE-- +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) +} From 01c1462b638c430de0523cc2097c44904a4e7e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CLamentXU123=E2=80=9D?= <108666168+LamentXU123@users.noreply.github.com> Date: Sat, 23 May 2026 12:44:28 +0800 Subject: [PATCH 2/2] fix test title --- ext/intl/tests/msgfmt_parse_int64_min_64.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/intl/tests/msgfmt_parse_int64_min_64.phpt b/ext/intl/tests/msgfmt_parse_int64_min_64.phpt index 932a888d686b..2d003667813c 100644 --- a/ext/intl/tests/msgfmt_parse_int64_min_64.phpt +++ b/ext/intl/tests/msgfmt_parse_int64_min_64.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug: MessageFormatter::parse() should preserve PHP_INT_MIN as int on 64-bit +MessageFormatter::parse() with PHP_INT_MIN on 64-bit platform --EXTENSIONS-- intl --SKIPIF--