Skip to content

GH-12943 ext/intl accept C as acceptable locale argument. #12955

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
wants to merge 1 commit into from
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
2 changes: 1 addition & 1 deletion ext/intl/dateformat/dateformat_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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) {
if (locale.isBogus() || ((locale_len == 1 && locale_str[0] != 'C') && strlen(locale.getISO3Language()) == 0)) {
goto error;
}

Expand Down
15 changes: 15 additions & 0 deletions ext/intl/tests/gh12943.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
GitHub #12943 IntlDateFormatter::locale accepting "C".
--EXTENSIONS--
intl
--FILE--
<?php

$fmt = new IntlDateFormatter(
'C',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
);
Comment on lines +8 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: CS

Suggested change
$fmt = new IntlDateFormatter(
'C',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
);
$fmt = new IntlDateFormatter(
'C',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
);

var_dump($fmt->getLocale(ULOC_VALID_LOCALE));
--EXPECTF--
string(%d) "%s"