Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85652 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52032 invoked from network); 1 Apr 2015 18:58:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Apr 2015 18:58:18 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.181 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.192.181 mail-pd0-f181.google.com Received: from [209.85.192.181] ([209.85.192.181:35142] helo=mail-pd0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/75-21906-9CF3C155 for ; Wed, 01 Apr 2015 13:58:17 -0500 Received: by pddn5 with SMTP id n5so63721749pdd.2 for ; Wed, 01 Apr 2015 11:58:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=piKBF5oKqlODT99Uu0g/YDP5ipsokctQ6o8rQfhakPc=; b=lJpTbTf8prwedL64n7/Qi67UV/SvUT5eMzpFGKqH6PL2yov0/SMbKawKSvX2ui0D3B AVe59v248EMJxv3Lf25RWXYPCKanOpLBhyJSi00Gv9+jKy8JB8cOuFf44Y3ZK0IXSK/Z +5trHP1nYuHyqpPk6nNOWx9iGGCGEjkd/Dp7Zj12+cteBtUQnr/CUnegPK4t6ZdHbu4M oolXwwdzn/7/I+cZTnamz1IfQdEiQwRGIbGlfkYwHX2xIgNSR5J5tcAsis+SJ3bvAN52 MxNnhsrN2MpCJPe6RYJbGSBhNIzaK4wfmwdBgL5LhTAnAckivZjQPwzx6ot23CsVHdBC dSNw== X-Received: by 10.70.93.4 with SMTP id cq4mr74832824pdb.163.1427914694119; Wed, 01 Apr 2015 11:58:14 -0700 (PDT) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id jx2sm2863732pbb.9.2015.04.01.11.58.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 11:58:13 -0700 (PDT) Message-ID: <551C3FC4.9050109@gmail.com> Date: Wed, 01 Apr 2015 11:58:12 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Dan Ackroyd , "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Deprecate setlocale? From: smalyshev@gmail.com (Stanislav Malyshev) 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 smalyshev@gmail.com