Hi all,
just integrating the SMS backend from Aleksander Adamowsky into notifications and wonder how to handle the setlocale() without having any side-effects. setlocale() is used here in the guess_locale() method, similar to projectmanger/inc/class.ganttchart.inc.php.
My concerns are:
-
setlocale sets the locale for a whole process, not just for a thread, so if multiple scripts run in this one process and notifications or projectmanager sets a local to e.g. “Russian”, could it happen that an e.g. English User gets a bad formatted date with strftime(), which returns a formatted date based on the locale.
-
setlocale could affect mysql queries, so if locales with switched point and commas for separators interfere, it could lead to bad queries.
So, can we use setlocale() in a safe way at all? Or should we drop it from our code?
Thx
Christian