From 0da1356c669a1396e02929724a72ee897d48c54c Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 30 Oct 2023 13:42:50 +0000 Subject: [PATCH 1/2] ext/intl: change when the locale is invalid for the 8.1/8.2 serie. does not throws an exception as it's considered as a too string change, but the code user still needs to double check. --- NEWS | 4 ++++ ext/intl/dateformat/dateformat_create.cpp | 3 +-- ext/intl/tests/gh12282.phpt | 15 ++++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 6dac57d6a3b..119d59b8906 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,10 @@ PHP NEWS . Fixed bug GH-12232 (FPM: segfault dynamically loading extension without opcache). (Jakub Zelenka) +- Intl: + . Removed the BC break on IntlDateFormatter::construct which threw an + exception with an invalid locale. (David Carlier) + - Opcache: . Added warning when JIT cannot be enabled. (danog) . Fixed bug GH-8143 (Crashes in zend_accel_inheritance_cache_find since diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp index e14eb4f1a2f..5c96f41fadf 100644 --- a/ext/intl/dateformat/dateformat_create.cpp +++ b/ext/intl/dateformat/dateformat_create.cpp @@ -113,8 +113,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin locale = Locale::createFromName(locale_str); /* get*Name accessors being set does not preclude being bogus */ if (locale.isBogus() || strlen(locale.getISO3Language()) == 0) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid locale", 0); - return FAILURE; + goto error; } /* process calendar */ diff --git a/ext/intl/tests/gh12282.phpt b/ext/intl/tests/gh12282.phpt index 62d090ba616..a30899a08c7 100644 --- a/ext/intl/tests/gh12282.phpt +++ b/ext/intl/tests/gh12282.phpt @@ -5,17 +5,18 @@ intl --FILE-- getMessage(); -} +)); +Locale::setDefault('xx'); +var_dump(new IntlDateFormatter(Locale::getDefault())); --EXPECT-- -datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR +object(IntlDateFormatter)#1 (0) { +} +object(IntlDateFormatter)#1 (0) { +} From 798b9d097b7ca83878983792378a1b9a39800f9d Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 2 Nov 2023 08:09:29 +0300 Subject: [PATCH 2/2] Fixed GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT --- Zend/Optimizer/zend_inference.c | 3 ++- ext/opcache/tests/opt/gh10008.phpt | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/opt/gh10008.phpt diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index 49dd44ff890..084a7abf9f7 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -2530,7 +2530,8 @@ static zend_always_inline int _zend_update_type_info( * unreachable code. Propagate the empty result early, so that that the following * code may assume that operands have at least one type. */ if (!(t1 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS)) - || !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))) { + || !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS)) + || (ssa_op->result_use >= 0 && !(RES_USE_INFO() & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS)))) { tmp = 0; if (ssa_op->result_def >= 0 && !(ssa_var_info[ssa_op->result_def].type & MAY_BE_REF)) { UPDATE_SSA_TYPE(tmp, ssa_op->result_def); diff --git a/ext/opcache/tests/opt/gh10008.phpt b/ext/opcache/tests/opt/gh10008.phpt new file mode 100644 index 00000000000..02f6feff9b0 --- /dev/null +++ b/ext/opcache/tests/opt/gh10008.phpt @@ -0,0 +1,26 @@ +--TEST-- +GH-10008: Narrowing occurred during type inference of ZEND_ADD_ARRAY_ELEMENT +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +--EXTENSIONS-- +opcache +--FILE-- + $bool_or_int, $string_key => 123]; + } + + $bool_or_int = 0; + } +} +?> +DONE +--EXPECT-- +DONE