[php-src] PR #20531: thread-safe and thread-local `setlocale()`
| From: | henderkes | Date: | Wed, 19 Nov 2025 17:32:18 +0000 |
| Subject: | [php-src] PR #20531: thread-safe and thread-local `setlocale()` | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34100@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20531
Author: henderkes
It's documented at https://www.php.net/manual/en/function.setlocale.php
that the
setlocale php function is not thread locale (and actually, not thread safe,
because the C setlocale function is
[MT-unsafe](https://man7.org/linux/man-pages/man3/setlocale.3.html#ATTRIBUTES). This leads to very
unexpected behaviour in FrankenPHP.
I would therefore like to propose changing setlocale to use POSIX
uselocale instead.
Unfortunately, because querylocale is only available on BSD, this adds a lot of string
caching logic to let users query for current locales, as I'm not aware of a different way.
Perhaps you can give me some pointers to avoid this logic.
The logic for windows remains unchanged.