Skip to content

Commit 198bf7f

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: ext/intl: Reset IntlListFormatter error state in constructor (#22931)
2 parents a5a9476 + 94d00c9 commit 198bf7f

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ PHP NEWS
1212
collator_asort() to report UTF-8/UTF-16 conversion errors through the intl
1313
error handler instead of emitting a warning and continuing with an empty
1414
string. (Weilin Du)
15+
. Fixed IntlListFormatter::__construct() leaving stale global error state
16+
after successful calls. (Weilin Du)
1517

1618
- Reflection:
1719
. Added ReflectionAttribute::inNamespace(),

ext/intl/listformatter/listformatter_class.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ PHP_METHOD(IntlListFormatter, __construct)
6767
zend_long type = INTL_LISTFORMATTER_FALLBACK_TYPE_AND;
6868
zend_long width = INTL_LISTFORMATTER_FALLBACK_WIDTH_WIDE;
6969
#endif
70+
71+
intl_errors_reset(LISTFORMATTER_ERROR_P(obj));
72+
7073
ZEND_PARSE_PARAMETERS_START(1, 3)
7174
Z_PARAM_STRING(locale, locale_len)
7275
Z_PARAM_OPTIONAL
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
IntlListFormatter::__construct() resets stale errors
3+
--EXTENSIONS--
4+
intl
5+
--FILE--
6+
<?php
7+
$formatter = new IntlListFormatter('en_US');
8+
var_dump($formatter->format(["\x80"]));
9+
var_dump(intl_get_error_code() === U_INVALID_CHAR_FOUND);
10+
11+
$formatter = new IntlListFormatter('en_US');
12+
var_dump(intl_get_error_code());
13+
var_dump(intl_get_error_message());
14+
var_dump($formatter->getErrorCode());
15+
var_dump($formatter->getErrorMessage());
16+
?>
17+
--EXPECT--
18+
bool(false)
19+
bool(true)
20+
int(0)
21+
string(12) "U_ZERO_ERROR"
22+
int(0)
23+
string(12) "U_ZERO_ERROR"

0 commit comments

Comments
 (0)