Commit 2d784891fff for php.net
commit 2d784891fff579eef86e326bf969e3cf41dc5244
Author: “LamentXU123” <108666168+LamentXU123@users.noreply.github.com>
Date: Sun May 17 22:29:49 2026 +0800
ext/intl: use PATTERN constant name in dateformat errors
close GH-22073
diff --git a/NEWS b/NEWS
index 8eaec1a74db..3413ff97c2b 100644
--- a/NEWS
+++ b/NEWS
@@ -8,8 +8,9 @@ PHP NEWS
and IntlGregorianCalendar date/time construction. (Weilin Du)
. Expose Spoofchecker restriction-level APIs on all supported ICU
versions. (Weilin Du)
- . Fix SpoofChecker::setAllowedChars() to report PHP constant names
- instead of ICU USET_* names in invalid pattern option errors.
+ . Fix SpoofChecker::setAllowedChars() and IntlDateFormatter::__construct()
+ to report PHP constant names instead of ICU constant names in
+ user-visible error messages.
(Weilin Du)
- MySQLnd:
diff --git a/UPGRADING b/UPGRADING
index b8be56f7791..50c58169528 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -92,8 +92,9 @@ PHP 8.4 UPGRADE NOTES
- ValueError if the integer index does not fit in a signed 32 bit integer
. IntlDateFormatter::__construct() throws a ValueError if the locale is invalid.
. NumberFormatter::__construct() throws a ValueError if the locale is invalid.
- . SpoofChecker::setAllowedChars() now reports PHP constant names instead
- of ICU USET_* names in invalid pattern option errors.
+ . SpoofChecker::setAllowedChars() and IntlDateFormatter::__construct()
+ now report PHP constant names instead of ICU constant names in
+ user-visible error messages.
. MBString:
. mb_encode_numericentity() and mb_decode_numericentity() now check that
the $map is only composed of integers, if not a ValueError is thrown.
diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp
index c2853bb906f..086c8678d56 100644
--- a/ext/intl/dateformat/dateformat_create.cpp
+++ b/ext/intl/dateformat/dateformat_create.cpp
@@ -103,7 +103,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
return FAILURE;
}
if (date_type == UDAT_PATTERN && time_type != UDAT_PATTERN) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: time format must be UDAT_PATTERN if date format is UDAT_PATTERN", 0);
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: time format must be IntlDateFormatter::PATTERN if date format is IntlDateFormatter::PATTERN", 0);
return FAILURE;
}
diff --git a/ext/intl/tests/gh12243.phpt b/ext/intl/tests/gh12243.phpt
index cb2b1776039..3b7a903a3bf 100644
--- a/ext/intl/tests/gh12243.phpt
+++ b/ext/intl/tests/gh12243.phpt
@@ -1,5 +1,5 @@
--TEST--
-GitHub #12043 segfault with IntlDateFormatter::dateType where it equals to UDAT_PATTERN (icu 50) but
+GitHub #12043 segfault with IntlDateFormatter::dateType where it equals to IntlDateFormatter::PATTERN (icu 50) but
IntldateFormatter::timeType needs to be set as such.
--EXTENSIONS--
intl
@@ -21,4 +21,4 @@
?>
--EXPECT--
-datefmt_create: time format must be UDAT_PATTERN if date format is UDAT_PATTERN: U_ILLEGAL_ARGUMENT_ERROR
+datefmt_create: time format must be IntlDateFormatter::PATTERN if date format is IntlDateFormatter::PATTERN: U_ILLEGAL_ARGUMENT_ERROR