Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85646 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41767 invoked from network); 1 Apr 2015 18:27:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Apr 2015 18:27:08 -0000 Authentication-Results: pb1.pair.com header.from=dev@mabe.berlin; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dev@mabe.berlin; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mabe.berlin from 80.237.132.167 cause and error) X-PHP-List-Original-Sender: dev@mabe.berlin X-Host-Fingerprint: 80.237.132.167 wp160.webpack.hosteurope.de Received: from [80.237.132.167] ([80.237.132.167:60798] helo=wp160.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B6/33-21906-9783C155 for ; Wed, 01 Apr 2015 13:27:07 -0500 Received: from dslb-178-002-078-042.178.002.pools.vodafone-ip.de ([178.2.78.42] helo=[192.168.178.30]); authenticated by wp160.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) id 1YdNLy-00088m-KW; Wed, 01 Apr 2015 20:27:02 +0200 Message-ID: <551C3876.5000004@mabe.berlin> Date: Wed, 01 Apr 2015 20:27:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-bounce-key: webpack.hosteurope.de;dev@mabe.berlin;1427912827;1a9d0a68; Subject: Re: [PHP-DEV] Deprecate setlocale? From: dev@mabe.berlin (Marc Bennewitz) Am 01.04.2015 um 18:15 schrieb Dan Ackroyd: > 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. What if the system is configured with a different locale? OK we could change the locale on startup to "C" but this could break embedded behaviour and doesn't solve the issue at all. There are some cases where we don't have a good alternative like fgetcsv / fputcsv. > 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. From my perspective Functionality not related to locale should not be effected by this global -> The following bug reports are valid bugs and should be resolved https://bugs.php.net/bug.php?id=59571 - breaks Imagick https://bugs.php.net/bug.php?id=69348 - breaks MySQL -> If it's part of the wrapped library it's a bug of this library and should be fixed there Basic PHP functions should be possible to be TS and therefore should ignoring such global configuration else it's impossible to have a TS version of PHP -> if there is no alternative functionality we should add one -> Non-TS functions should be moved into an extension and don't allow to enable on TS build -> Non-TS functions not movable to an extension should be rethink like: - removing the locale based conversion on simple float to string casts - make strtoupper/strtolower etc. to work with ascii only Is't there a very similar issue with fs operations and umask? -> Is it possible to have fs operations not related on this non-TS global configuration? > https://bugs.php.net/bug.php?id=59571 - breaks Imagick -> It's a real bug and should be fixed (not locale based functionality) > https://bugs.php.net/bug.php?id=54538 - breaks NumberFormatter -> It's a real bug and should be fixed (based on a different "safe" locale) > https://bugs.php.net/bug.php?id=66108 - breaks constants -> see comment above about strtoupper > https://bugs.php.net/bug.php?id=67127 - breaks DateTime -> It's a bug and should be fixed (not locale based functionality) > https://bugs.php.net/bug.php?id=69348 - breaks MySQL -> It's a bug and should be fixed (non locale based functionality) -> Couldn't this one be a security issue > > 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 > Marc