Skip to content

Commit ff095cc

Browse files
committed
Merge branch 'PHP-8.3'
2 parents 8a812c3 + 35a502f commit ff095cc

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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)