Skip to content

Commit 35a502f

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents b08802d + 63150dc commit 35a502f

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ PHP NEWS
2121
. Fixed bug GH-12186 (segfault copying/cloning a finalized HashContext).
2222
(MaxSem)
2323

24+
- Intl:
25+
. Fixed bug GH-12243 (segfault on IntlDateFormatter::construct).
26+
(David Carlier)
27+
2428
- SimpleXML:
2529
. Fixed bug GH-12170 (Can't use xpath with comments in SimpleXML). (nielsdos)
2630
. Fixed bug GH-12192 (SimpleXML infinite loop when getName() is called

ext/intl/dateformat/dateformat_create.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
9999
}
100100
if (!INTL_UDATE_FMT_OK(time_type)) {
101101
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid time format style", 0);
102-
return FAILURE;
102+
return FAILURE;
103+
}
104+
if (date_type == UDAT_PATTERN && time_type != UDAT_PATTERN) {
105+
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: time format must be UDAT_PATTERN if date format is UDAT_PATTERN", 0);
106+
return FAILURE;
103107
}
104108

105109
INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);

ext/intl/tests/gh12243.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GitHub #12043 segfault with IntlDateFormatter::dateType where it equals to UDAT_PATTERN (icu 50) but
3+
IntldateFormatter::timeType needs to be set as such.
4+
--EXTENSIONS--
5+
intl
6+
--FILE--
7+
<?php
8+
9+
$datetime = new \DateTime('2017-05-12 23:11:00 GMT+2');
10+
static $UDAT_PATTERN = -2;
11+
12+
try {
13+
new IntlDateFormatter(
14+
locale: 'en',
15+
dateType: $UDAT_PATTERN,
16+
timeType: 0,
17+
timezone: $datetime->getTimezone(),
18+
);
19+
} catch (\IntlException $e) {
20+
echo $e->getMessage();
21+
}
22+
23+
--EXPECT--
24+
datefmt_create: time format must be UDAT_PATTERN if date format is UDAT_PATTERN: U_ILLEGAL_ARGUMENT_ERROR

0 commit comments

Comments
 (0)