Commit eeb12a4e288 for php.net
commit eeb12a4e288f774c48f3022fd7572771ba0bde9a
Author: Weilin Du <108666168+LamentXU123@users.noreply.github.com>
Date: Sun May 24 17:41:48 2026 +0800
ext/Intl: Return PHP_INT_MIN as int from MessageFormatter::parse() on 64-bit (#22131)
diff --git a/NEWS b/NEWS
index e37effff3af..3bb752f5c8b 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 a3b22d8c056..7f805496db7 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 f504ee50abc..12e05af5721 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 00000000000..2d003667813
--- /dev/null
+++ b/ext/intl/tests/msgfmt_parse_int64_min_64.phpt
@@ -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)
+}