Hi,

I'd like to get people's feedback for the idea of making setlocale be
either deprecated and to be removed eventually or just increasing the
warning level against people using it.

The short version of why we should do this is that setlocale breaks
things. It is a process wide operation, that is not thread safe on
most platforms. Although people use it to alter the way strings are
output, it also breaks libraries that are assuming that they are
running in a "C" locale.

https://bugs.php.net/bug.php?id=59571 - breaks Imagick
https://bugs.php.net/bug.php?id=54538 - breaks NumberFormatter
https://bugs.php.net/bug.php?id=66108 - breaks constants
https://bugs.php.net/bug.php?id=67127 - breaks DateTime
https://bugs.php.net/bug.php?id=69348 - breaks MySQL

And there are quite a few other bug reports where setlocale is doing
exactly what it is meant to do, but the unexpected side-effects are
catching people out.

We have libraries that ship with PHP for formatting dates, numbers etc
that actually work, and don't break other libraries.

So two questions:

i) Are there any reasons why we couldn't or shouldn't plan for
removing setlocale at some point in the future? i.e. does it do
something that isn't supported by other libraries in PHP?

ii) If it's not possible (or desirable) to remove it, how could we
increase the warning level against using it?

cheers
Dan

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to