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

2
  • Did you read this? Commented Jul 18, 2012 at 15:05
  • yes. I thought though that this was not relevant to me since Apache on my server is running in prefork mode Commented Jul 18, 2012 at 15:15

1 Answer 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.

Sign up to request clarification or add additional context in comments.

1 Comment

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.