Skip to content

ext/intl: change when the locale is invalid for the 8.1/8.2 serie. #12568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ext/intl/dateformat/dateformat_create.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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) {
}