|
Posted by OmegaJunior on 02/17/07 09:19
On Sat, 17 Feb 2007 00:03:34 +0100, Daniele C.
<legolas558@users.sourceforge.net> wrote:
> I will report a snippet from http://php.net/setlocale
>
>> Warning
>>
>> The locale information is maintained per process, not per thread. If
>> you are running PHP on a multithreaded server api like IIS or Apache on
>> Windows you may experience sudden changes of locale settings while a
>> script is running although the script itself never called setlocale()
>> itself. This happens due to other scripts running in different threads
>> of the same process at the same time changing the processwide locale
>> using setlocale().
>>
>
> I spent about 2 seconds before thinking: can it really be? I mean, is
> there no way to set locale info per thread? And after a brief web
> search I came up with this keyword: _configthreadlocale
>
> Read more at
> http://msdn2.microsoft.com/en-us/library//26c0tb7x(VS.80).aspx
> (beware, this page is very slow or their servers are anyway).
> Looks like this function exists since Windows 95 and guess what it
> does: it affects the behaviour of the locale functions so that _each
> thread will have indipendent locale settings_.
>
> So, I though: WHY? Why does not PHP use such function in the win32
> binding?
>
> Let's be clear, I don't think to have found a solution that PHP
> developers could not find, but I would like to know why they did not
> fix the bad behaviour of PHP's setlocale() function using the
> configthreadlocale() win32 function, there must be some reason I
> really could not think about up to now.
>
> I really hope somebody can point me to something to read about this
> topic (I found pretty nothing up to now) or better directly explain it
> to me.
>
> Thank you
> --
> Daniele C.
>
How is PHP supposed to react when someone on the server changes the locale
settings while services are running? Do you expect the PHP language to
retain every possible OS setting in memory? That could be doable, but what
if the setting needed to be changed? And PHP keeps running with an
outdated setting because it cached it? No. Better to read it from the OS
every time it's needed. Yes, that will make it possible for things to
change during script execution. And if your scripts are locale-aware, you
should already have programmed that possibility into your scripts.
You can compare it to the time setting. If the server admin decides to
change the time on the server, it may happen in between executions of
script. That means the first execution has the old time, while the next
has the new time. Is this a problem? Not in most applications. But it is
in time-depending ones. And those should already have taken that
possibility into account.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Navigation:
[Reply to this message]
|