0

I have a problem with a PHP script sometimes triggering weird warnings in the Apache error log :

bash: warning: setlocale: LC_ALL: cannot change locale (fr_FR.utf8)
bash: warning: setlocale: LC_ALL: cannot change locale (fr_FR.utf8)
bash: warning: setlocale: LC_ALL: cannot change locale (fr_FR.utf8)
bash: warning: setlocale: LC_ALL: cannot change locale (fr_FR.utf8)

Below is the code generating this warning. (it is used to configure gettext).

    $lang='fr_FR.utf8';
    $filename = 'default';
    putenv("LC_ALL=$lang");
    setlocale(LC_ALL, $lang);
    bindtextdomain($filename, './config/locale');
    bind_textdomain_codeset($filename, "UTF-8");
    textdomain($filename);

The weird thing is that the warning does not systematically appear. If I restart Apache, it will not appear for some minutes (i.e. serving hundreds of requests without any warning) and then it will progressively start appearing.

Thank you


  • Did you read this? - RobIII
  • yes. I thought though that this was not relevant to me since Apache on my server is running in prefork mode - David

1 답변


0

setlocale is not thread safe (See What does thread safe mean in a PHP context?. That's why the Zend Framework implements their own Locale system.


  • thought this wouldn't be a problem as my Apache is running in prefork mode? - David

Linked


Related

Latest