Re: Deprecate setlocale?
| From: | Michael Wallner | Date: | Wed, 01 Apr 2015 17:08:13 +0000 |
| Subject: | Re: Deprecate setlocale? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85640@lists.php.net to get a copy of this message | ||
> On 01 04 2015, at 18:15, Dan Ackroyd <danack@basereality.com> wrote:
>
> 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?
>
-1
I don’t hink that we should restrict access to standard library functions just because something
might break due to usage under wrong assumptions.
> ii) If it's not possible (or desirable) to remove it, how could we
> increase the warning level against using it?