Re: setlocale Apache/PHP problem - tentative bug.
| From: | Jouni Ahto | Date: | Wed, 06 Oct 1999 22:31:17 +0000 |
| Subject: | Re: setlocale Apache/PHP problem - tentative bug. | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-11587@lists.php.net to get a copy of this message | ||
On Wed, 6 Oct 1999, Christian Reis wrote:
> I'm not saying 'BUG' yet, but..
>
> We're using multiple locales here - and we're having a heap of trouble.
> I'm isolating the problem to either Apache or PHP, but I'm asking first to
> know if anybody's done the same, and then inviting anyone to test for the
> same error.
>
> This is php-3.0.12 both DSO and static on apache-1.3.9.
> I've seen this problem on apache-1.3.6, php-3.0.11.
>
> I infer the problem is:
>
> setlocale is [cached,kept] over a session on the httpd process that ran.
PHP just calls setlocale() in your c-library. setlocale() changes
permanently the calling programs environment. There is no caching of
locale in PHP.
> I setlocale("LC_ALL","pt_BR") on a certain page. Execution goes fine and I
> can use by brazilian date names fine.
>
> I then open another _totally unrelated_ page. There is _no_ setlocale
> statement in the page's script; a simple strftime. I assume the locale
> should be "C" - the default locale. I'm running httpd with no LANG
> environment variable set.
>
> This is the interesting part:
>
> - _OCCASIONALLY_, we get brazilian date names. This is quite
> reproducible, but happens erraticly. I _THINK_ this is because we're being
> run by the httpd daemon that executed the setlocale previously. I say
> _THINK_ because if I issue no setlocale ever (since apache's startup) I
> never get the changed locale. I've echoed the locale onto a page and it's
> really set to pt_BR sometimes, and C others.
You think right. That's the cause of your problem. Do setlocale("LC_ALL",
"C") at the end of the page where you changed the locale to pt_BR and
everything is fine.
Jouni Ahto