Issue Task Under Review

#110967Stop changing the process locale per frontend request

Benni Mack 10/08/26, 13:42 updated 11/10/26, 17:12

Description

SiteResolver calls Locales::setSystemLocaleFromSiteLanguage() on every frontend request. That sets LC_COLLATE, LC_CTYPE, LC_MONETARY and LC_TIME from the locale of the site language.

setlocale() changes state for the whole process. The PHP manual warns that on multithreaded SAPIs the locale is shared by all threads. On thread-based runtimes such as FrankenPHP, a request can therefore change the locale under another request running at the same time. In worker mode, the locale would also carry over to later requests.

Core only reads this locale in three places:

- DateFormatter::strftime() falls back to setlocale(LC_TIME, ‘0’) when it gets no locale. In practice this affects TypoScript stdWrap.strftime.
- GeneralUtility::formatSize() reads decimal and thousands separators via localeconv(). It temporarily changes LC_NUMERIC to do so.
- SelectViewHelper and CountrySelectViewHelper sort options with SORT_LOCALE_STRING.

Since PHP 8.2, case conversion (strtolower(), ucfirst(), …) no longer depends on the locale.

Reviews 1

History 03