Skip to content

ext/intl: backport IntlDateFormatter fix. #13107

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

Open
wants to merge 1 commit into
base: PHP-8.1
Choose a base branch
from
Open
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') || (locale_len > 1 && 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,
);
var_dump($fmt->getLocale(ULOC_VALID_LOCALE));
--EXPECTF--
string(%d) "%s"