Hi!

> 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.

Library should not assume it runs in C locale, since this may be not
true regardless of whether we ever used setlocale in PHP code, since
locale is a system setting. That said, locale is a remanant of the times
where the assumption that all processes on the machine do approximately
the same thing and service the same goal for a single client or set of
clients small enough that they are all likely be in the same place was
entirely reasonable. Of course, for a webserver this sounds like utter
madness.
That said, there may be scenarios where this is still useful (such as,
small server-side scripts, etc.) so I'm not sure we should really
deprecate it. I'd rather add a large warning to its man page that
setlocale does more than you think and you should be careful with it (of
course, not in these words :)

> https://bugs.php.net/bug.php?id=59571 - breaks Imagick
> https://bugs.php.net/bug.php?id=54538 - breaks NumberFormatter

This one is a bug in ICU.

> https://bugs.php.net/bug.php?id=66108 - breaks constants

This seems to be a bug. I though I've fixed the case conversion to use
ascii, but maybe I missed a spot in constant(). I'll check it.

> https://bugs.php.net/bug.php?id=67127 - breaks DateTime

This looks like misunderstanding how float-to-string works. If you asked
it to put commas as decimal separator, don't be surprised it puts commas
as decimal separator.

> https://bugs.php.net/bug.php?id=69348 - breaks MySQL

This doesn't seem to be a mysql problem but rather misunderstanding how
type conversion works. Same as above.

> 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?

I don't think we should remove it. I do think we should warn people that
in this day and age, setlocale() is very bad way of doing
internationalization except for very specific cases when you know what
you are doing.

-- 
Stas Malyshev
smalys...@gmail.com

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

Reply via email to