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.
This commit is contained in:
David Carlier 2023-10-30 13:42:50 +00:00
parent fe3a819e32
commit 0da1356c66
3 changed files with 13 additions and 9 deletions

4
NEWS
View file

@ -19,6 +19,10 @@ PHP NEWS
. Fixed bug GH-12232 (FPM: segfault dynamically loading extension without . Fixed bug GH-12232 (FPM: segfault dynamically loading extension without
opcache). (Jakub Zelenka) opcache). (Jakub Zelenka)
- Intl:
. Removed the BC break on IntlDateFormatter::construct which threw an
exception with an invalid locale. (David Carlier)
- Opcache: - Opcache:
. Added warning when JIT cannot be enabled. (danog) . Added warning when JIT cannot be enabled. (danog)
. Fixed bug GH-8143 (Crashes in zend_accel_inheritance_cache_find since . Fixed bug GH-8143 (Crashes in zend_accel_inheritance_cache_find since

View file

@ -113,8 +113,7 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
locale = Locale::createFromName(locale_str); locale = Locale::createFromName(locale_str);
/* get*Name accessors being set does not preclude being bogus */ /* get*Name accessors being set does not preclude being bogus */
if (locale.isBogus() || strlen(locale.getISO3Language()) == 0) { if (locale.isBogus() || strlen(locale.getISO3Language()) == 0) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid locale", 0); goto error;
return FAILURE;
} }
/* process calendar */ /* process calendar */

View file

@ -5,17 +5,18 @@ intl
--FILE-- --FILE--
<?php <?php
try { var_dump(new IntlDateFormatter(
new IntlDateFormatter(
'xx', 'xx',
IntlDateFormatter::FULL, IntlDateFormatter::FULL,
IntlDateFormatter::FULL, IntlDateFormatter::FULL,
null, null,
null, null,
'w' 'w'
); ));
} catch (\IntlException $e) { Locale::setDefault('xx');
echo $e->getMessage(); var_dump(new IntlDateFormatter(Locale::getDefault()));
}
--EXPECT-- --EXPECT--
datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR object(IntlDateFormatter)#1 (0) {
}
object(IntlDateFormatter)#1 (0) {
}