shaarli / Shaarli

The personal, minimalist, super-fast, database free, bookmarking service - community repo
https://shaarli.readthedocs.io/
Other
3.43k stars 291 forks source link

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

Closed nodiscc closed 11 months ago

nodiscc commented 12 months ago

The automatic test suite started failing for PHP 8.1 and 8.2 after https://github.com/shaarli/Shaarli/pull/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 commented 11 months ago

Probably caused by the fix for https://github.com/php/php-src/issues/12282 which landed in PHP 8.2.12 and 8.1.25

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

filozofer commented 11 months ago

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 commented 11 months ago

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 https://github.com/php/php-src/issues/12561.

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

filozofer commented 11 months ago

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