Skip to content

Commit

Permalink
ext/intl: change when the locale is invalid for the 8.1/8.2 serie.
Browse files Browse the repository at this point in the history
does not throws an exception as it's considered as a too string change,
but the code user still needs to double check.
  • Loading branch information
devnexen committed Nov 1, 2023
1 parent fe3a819 commit 0da1356
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions ext/intl/dateformat/dateformat_create.cpp
Expand Up @@ -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 */
Expand Down
15 changes: 8 additions & 7 deletions ext/intl/tests/gh12282.phpt
Expand Up @@ -5,17 +5,18 @@ intl
--FILE--
<?php

try {
new IntlDateFormatter(
var_dump(new IntlDateFormatter(
'xx',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
null,
null,
'w'
);
} catch (\IntlException $e) {
echo $e->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) {
}

0 comments on commit 0da1356

Please sign in to comment.