Skip to content

Commit 22735b3

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fixed GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT ext/intl: change when the locale is invalid for the 8.1/8.2 serie.
2 parents d4183c2 + 177a6f5 commit 22735b3

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ PHP NEWS
2828
. Fixed bug GH-12232 (FPM: segfault dynamically loading extension without
2929
opcache). (Jakub Zelenka)
3030

31+
- Intl:
32+
. Removed the BC break on IntlDateFormatter::construct which threw an
33+
exception with an invalid locale. (David Carlier)
34+
3135
- Opcache:
3236
. Added warning when JIT cannot be enabled. (danog)
3337
. Fixed bug GH-8143 (Crashes in zend_accel_inheritance_cache_find since

Zend/Optimizer/zend_inference.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,6 +2545,7 @@ static zend_always_inline zend_result _zend_update_type_info(
25452545
* code may assume that operands have at least one type. */
25462546
if (!(t1 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))
25472547
|| !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))
2548+
|| (ssa_op->result_use >= 0 && !(RES_USE_INFO() & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS)))
25482549
|| ((opline->opcode == ZEND_ASSIGN_DIM_OP
25492550
|| opline->opcode == ZEND_ASSIGN_OBJ_OP
25502551
|| opline->opcode == ZEND_ASSIGN_STATIC_PROP_OP

ext/intl/dateformat/dateformat_create.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
113113
locale = Locale::createFromName(locale_str);
114114
/* get*Name accessors being set does not preclude being bogus */
115115
if (locale.isBogus() || strlen(locale.getISO3Language()) == 0) {
116-
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid locale", 0);
117-
return FAILURE;
116+
goto error;
118117
}
119118

120119
/* process calendar */

ext/intl/tests/gh12282.phpt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ intl
55
--FILE--
66
<?php
77

8-
try {
9-
new IntlDateFormatter(
8+
var_dump(new IntlDateFormatter(
109
'xx',
1110
IntlDateFormatter::FULL,
1211
IntlDateFormatter::FULL,
1312
null,
1413
null,
1514
'w'
16-
);
17-
} catch (\IntlException $e) {
18-
echo $e->getMessage();
19-
}
15+
));
16+
Locale::setDefault('xx');
17+
var_dump(new IntlDateFormatter(Locale::getDefault()));
2018
--EXPECT--
21-
datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR
19+
object(IntlDateFormatter)#1 (0) {
20+
}
21+
object(IntlDateFormatter)#1 (0) {
22+
}

ext/opcache/tests/opt/gh10008.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
--EXTENSIONS--
7+
opcache
8+
--FILE--
9+
<?php
10+
function test()
11+
{
12+
$bool_or_int = true;
13+
while (a()) {
14+
if ($bool_or_int !== true) {
15+
// The following line triggers narrowing during type inference of ZEND_ADD_ARRAY_ELEMENT.
16+
$string_key = "a";
17+
$array = ["bool_or_int" => $bool_or_int, $string_key => 123];
18+
}
19+
20+
$bool_or_int = 0;
21+
}
22+
}
23+
?>
24+
DONE
25+
--EXPECT--
26+
DONE

0 commit comments

Comments
 (0)