Skip to content

Commit 6a447e7

Browse files
committed
GH-12943 ext/intl accept C as acceptable locale argument.
Close GH-12955
1 parent b3f483d commit 6a447e7

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ PHP NEWS
1717
(Jakub Zelenka)
1818
. Fixed bug GH-12905 (FFI::new interacts badly with observers). (nielsdos)
1919

20+
- Intl:
21+
. Fixed GH-12943 (IntlDateFormatter::__construct accepts 'C' as valid locale).
22+
(David Carlier)
23+
2024
- Hash:
2125
. Fixed bug GH-12936 (hash() function hangs endlessly if using sha512 on
2226
strings >= 4GiB). (nielsdos)

ext/intl/dateformat/dateformat_create.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
112112
}
113113
locale = Locale::createFromName(locale_str);
114114
/* get*Name accessors being set does not preclude being bogus */
115-
if (locale.isBogus() || strlen(locale.getISO3Language()) == 0) {
115+
if (locale.isBogus() || ((locale_len == 1 && locale_str[0] != 'C') && strlen(locale.getISO3Language()) == 0)) {
116116
goto error;
117117
}
118118

ext/intl/tests/gh12943.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
GitHub #12943 IntlDateFormatter::locale accepting "C".
3+
--EXTENSIONS--
4+
intl
5+
--FILE--
6+
<?php
7+
8+
$fmt = new IntlDateFormatter(
9+
'C',
10+
IntlDateFormatter::FULL,
11+
IntlDateFormatter::FULL,
12+
);
13+
var_dump($fmt->getLocale(ULOC_VALID_LOCALE));
14+
--EXPECTF--
15+
string(%d) "%s"

0 commit comments

Comments
 (0)