Review 12.4 Merged

81335[BUGFIX] Mitigate locale `C` in `DateFormatter` wrapping class

Stefan Bürk CR +2 V +2 Normal +51 −8 updated 10/05/23, 14:56

Commit message

Since PHP 8.3.0RC3 [1] the `\IntlDateFormatter` throws a
`\IntlException` exception with the message:

    datefmt_create: invalid locale: U_ILLEGAL_ARGUMENT_ERROR

if an invalid locale is passed to the constructor. The value `C`
is considered as a non-valid locale, albeit it may be set.

This change introduces a fallback to `en-US` for the two methods
of the `\TYPO3\CMS\Core\Localization\DateFormatter` wrapping class,
if `C` is passed as locale.

`en-US` has been chosen as fallback because the TYPO3 locale class
`\TYPO3\CMS\Core\Localization\Locale` uses the same as fallback if
`C` is provided and additional tests are added to cover the same
behaviour.

Note: Other illegal locales are not handled and will allow the
      exception to bubble up with PHP8.3+.

[1] https://github.com/php/php-src/commit/a80db7b52aa134bdc8b9841

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
  • Verified V +2 Done
    • Stefan Bürk +2
    • core-ci +1 CI

Issues 1

Files 2

Review log 34

  1. Stefan Bürk commented on patch set 1 10/05/23, 14:47

    Cherry Picked from branch main.
  2. core-ci voted on patch set 1 V +1 10/05/23, 14:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47446

  3. Stefan Bürk voted on patch set 1 V +2 CR +2 10/05/23, 14:56

  4. Stefan Bürk merged patch set 2 10/05/23, 14:56