Skip to content
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

tests: IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR (PHP 8.2.12) #2029

Closed
nodiscc opened this issue Nov 1, 2023 · 4 comments · Fixed by #2044
Closed
Labels
bug it's broken! php compatibility php version support tools developer tools
Milestone

Comments

@nodiscc
Copy link
Member

nodiscc commented Nov 1, 2023

The automatic test suite started failing for PHP 8.1 and 8.2 after #2028 which is just a documentation update and doesn't touch dependencies or application code.

https://github.com/shaarli/Shaarli/actions/workflows/ci.yml

-------
PHPUNIT
-------
PHPUnit 9.6.13 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

...............................................................  63 / 993 (  6%)
............................................................... 126 / 993 ( 12%)
............................................................... 189 / 993 ( 19%)
............................................................... 252 / 993 ( 25%)
............................................................... 315 / 993 ( 31%)
............................................................... 378 / 993 ( 38%)
.............................E................................. 441 / 993 ( 44%)
...........................................................EEEE 504 / 993 ( 50%)
E..E.E.........E............................................... 567 / 993 ( 57%)
............................................................... 630 / 993 ( 63%)
.EEEE.EEEE..................................................... 693 / 993 ( 69%)
............................................................... 756 / 993 ( 76%)
............................................................... 819 / 993 ( 82%)
............................................................... 882 / 993 ( 88%)
............................................................... 945 / 993 ( 95%)
................................................                993 / 993 (100%)

Time: 00:08.695, Memory: 62.00 MB

There were 17 errors:

1) Shaarli\Front\Controller\Admin\ServerControllerTest::testIndex
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/front/controller/admin/ServerController.php:48
/home/runner/work/Shaarli/Shaarli/tests/front/controller/admin/ServerControllerTest.php:61
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

2) Shaarli\Front\Controller\Visitor\DailyControllerTest::testValidIndexControllerInvokeDefault
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/application/front/controller/visitor/DailyController.php:35
/home/runner/work/Shaarli/Shaarli/tests/front/controller/visitor/DailyControllerTest.php:100
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

3) Shaarli\Front\Controller\Visitor\DailyControllerTest::testValidIndexControllerInvokeNoFutureOrPast
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/application/front/controller/visitor/DailyController.php:35
/home/runner/work/Shaarli/Shaarli/tests/front/controller/visitor/DailyControllerTest.php:223
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

4) Shaarli\Front\Controller\Visitor\DailyControllerTest::testValidIndexControllerInvokeHeightAdjustment
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/application/front/controller/visitor/DailyController.php:35
/home/runner/work/Shaarli/Shaarli/tests/front/controller/visitor/DailyControllerTest.php:281
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

5) Shaarli\Front\Controller\Visitor\DailyControllerTest::testValidIndexControllerInvokeNoBookmark
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/application/front/controller/visitor/DailyController.php:35
/home/runner/work/Shaarli/Shaarli/tests/front/controller/visitor/DailyControllerTest.php:328
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

6) Shaarli\Front\Controller\Visitor\DailyControllerTest::testValidRssControllerInvokeDefault
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/application/front/controller/visitor/DailyController.php:135
/home/runner/work/Shaarli/Shaarli/tests/front/controller/visitor/DailyControllerTest.php:377
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

7) Shaarli\Front\Controller\Visitor\DailyControllerTest::testSimpleIndexWeekly
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:184
/home/runner/work/Shaarli/Shaarli/application/front/controller/visitor/DailyController.php:35
/home/runner/work/Shaarli/Shaarli/tests/front/controller/visitor/DailyControllerTest.php:522
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

8) Shaarli\Front\Controller\Visitor\DailyControllerTest::testSimpleRssWeekly
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:184
/home/runner/work/Shaarli/Shaarli/application/front/controller/visitor/DailyController.php:135
/home/runner/work/Shaarli/Shaarli/tests/front/controller/visitor/DailyControllerTest.php:634
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

9) Shaarli\Front\Controller\Visitor\InstallControllerTest::testInstallIndexWithValidSession
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/front/controller/visitor/InstallController.php:65
/home/runner/work/Shaarli/Shaarli/tests/front/controller/visitor/InstallControllerTest.php:66
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

10) Shaarli\Helper\DailyPageHelperTest::testGeDescriptionsByType with data set #0 ('day', DateTimeImmutable Object (...), 'Today - November 1, 2023')
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/tests/helper/DailyPageHelperTest.php:122
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

11) Shaarli\Helper\DailyPageHelperTest::testGeDescriptionsByType with data set #1 ('day', DateTimeImmutable Object (...), 'Yesterday - October 31, 2023')
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/tests/helper/DailyPageHelperTest.php:122
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

12) Shaarli\Helper\DailyPageHelperTest::testGeDescriptionsByType with data set #2 ('day', DateTimeImmutable Object (...), 'October 9, 2020')
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/tests/helper/DailyPageHelperTest.php:122
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

13) Shaarli\Helper\DailyPageHelperTest::testGeDescriptionsByType with data set #3 ('week', DateTimeImmutable Object (...), 'Week 41 (October 5, 2020)')
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:184
/home/runner/work/Shaarli/Shaarli/tests/helper/DailyPageHelperTest.php:122
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

14) Shaarli\Helper\DailyPageHelperTest::testGeDescriptionsByTypeNotIncludeRelative with data set #0 ('day', DateTimeImmutable Object (...), 'November 1, 2023')
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/tests/helper/DailyPageHelperTest.php:135
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

15) Shaarli\Helper\DailyPageHelperTest::testGeDescriptionsByTypeNotIncludeRelative with data set #1 ('day', DateTimeImmutable Object (...), 'October 31, 2023')
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/tests/helper/DailyPageHelperTest.php:135
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

16) Shaarli\Helper\DailyPageHelperTest::testGeDescriptionsByTypeNotIncludeRelative with data set #2 ('day', DateTimeImmutable Object (...), 'October 9, 2020')
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:192
/home/runner/work/Shaarli/Shaarli/tests/helper/DailyPageHelperTest.php:135
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

17) Shaarli\Helper\DailyPageHelperTest::testGeDescriptionsByTypeNotIncludeRelative with data set #3 ('week', DateTimeImmutable Object (...), 'Week 41 (October 5, 2020)')
IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

/home/runner/work/Shaarli/Shaarli/application/Utils.php:327
/home/runner/work/Shaarli/Shaarli/application/helper/DailyPageHelper.php:184
/home/runner/work/Shaarli/Shaarli/tests/helper/DailyPageHelperTest.php:135
/home/runner/work/Shaarli/Shaarli/vendor/bin/phpunit:122

ERRORS!
Tests: 993, Assertions: 4038, Errors: 17.

Generating code coverage report in PHP format ... done [00:00.027]
make: *** [Makefile:76: test] Error 2
Error: Process completed with exit code 2.
@nodiscc nodiscc added bug it's broken! tools developer tools php compatibility php version support labels Nov 1, 2023
@nodiscc nodiscc added this to the 0.13.0 milestone Nov 1, 2023
@nodiscc
Copy link
Member Author

nodiscc commented Nov 2, 2023

Probably caused by the fix for php/php-src#12282 which landed in PHP 8.2.12 and 8.1.25

Edit: php/php-src#12561, it might still get fixed upstream, so let's wait.

@filozofer
Copy link

We have update our php version to the lastest yesterday (8.2.12) and the bug still provoke 500 in our production environment :
Uncaught PHP Exception IntlException: "datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR" at /var/www/web/vendor/symfony/form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php line 179

Concern line in Symfony core :
$intlDateFormatter = new \IntlDateFormatter(\Locale::getDefault(), $dateFormat, $timeFormat, $timezone, $calendar, $pattern ?? '');

With inputs :

input value
calendar 1
dateType 2
locale cz
pattern yyyy-MM-dd
timeType -1
timezone Object DateTimeZone

So it seems than "cz" locale is considerate as an invalid locale ><
CZ is part of the Iana list of language : https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

Type: region
Subtag: CZ
Description: Czechia
Description: Czech Republic
Added: 2005-10-16

So... bug or misconfiguration of our app ?

@nodiscc
Copy link
Member Author

nodiscc commented Nov 9, 2023

The bug was introduced in PHP 8.2.12 - technically not a "bug" but .patch version upgrades should not break backwards compatibility, so the change will be reverted in PHP 8.2.13 and 8.1.26, see php/php-src#12561.

The path of least resistance is to not upgrade to PHP 8.2.12 and wait for the next PHP release.

@nodiscc nodiscc changed the title tests: IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR tests: IntlException: datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR (PHP 8.2.12) Nov 9, 2023
@filozofer
Copy link

We pass our users from "cz" locale to "cs" and it works again. Thanx for your response.

@nodiscc nodiscc modified the milestones: 0.13.0, 0.14.0 Nov 22, 2023
ArthurHoaro added a commit to ArthurHoaro/Shaarli that referenced this issue Nov 25, 2023
PHP 8.2.13 and 8.1.26 introduced another error preventing the CI to pass
with default POSIX locale. We now have a wrapper to get the locale and
replace C with a valid locale.

@see php/php-src#12561

Fixes shaarli#2029
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug it's broken! php compatibility php version support tools developer tools
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants