1

I experienced a bug with php-fpm : locale settings change themselves randomly.

Here are the correct locale settings:

Array
(
    [decimal_point] => .
    [thousands_sep] => 
    [int_curr_symbol] => 
    [currency_symbol] => 
    [mon_decimal_point] => 
    [mon_thousands_sep] => 
    [positive_sign] => 
    [negative_sign] => 
    [int_frac_digits] => 127
    [frac_digits] => 127
    [p_cs_precedes] => 127
    [p_sep_by_space] => 127
    [n_cs_precedes] => 127
    [n_sep_by_space] => 127
    [p_sign_posn] => 127
    [n_sign_posn] => 127
    [grouping] => Array
        (
        )
    [mon_grouping] => Array
        (
        )
)

And here are the changed settings:

Array
(
    [decimal_point] => ,
    [thousands_sep] =>  
    [int_curr_symbol] => EUR 
    [currency_symbol] => €
    [mon_decimal_point] => ,
    [mon_thousands_sep] =>  
    [positive_sign] => 
    [negative_sign] => -
    [int_frac_digits] => 2
    [frac_digits] => 2
    [p_cs_precedes] => 0
    [p_sep_by_space] => 1
    [n_cs_precedes] => 0
    [n_sep_by_space] => 1
    [p_sign_posn] => 1
    [n_sign_posn] => 1
    [grouping] => Array
        (
            [0] => 3
        )
    [mon_grouping] => Array
        (
            [0] => 3
        )
)

The problem occurs randomly.

When removing php-fpm and using FastCGI, the problem doesn't occur anymore. How can I get this working with php-fpm ? The problem occurs on a shared hosting (we are the company which provides the hosting) and we really need php-fpm in order to use pools.

Thanks in advance!

EDIT : Today I discovered the problem occurs when we use the Ondemand Process Manager and not with the Static Process Manager.

1
  • Do you run separate PHP-FPM pools for all your different customers? I think a single PHP-FPM pool retains the locale settings across sessions, and that is what causes your problems. Jun 2, 2015 at 14:12

1 Answer 1

0

This strong warning in the PHP documentation explains the problem:

Warning The locale information is maintained per process, not per thread. If you are running PHP on a multithreaded server API like IIS, HHVM or Apache on Windows, you may experience sudden changes in locale settings while a script is running, though the script itself never called setlocale(). This happens due to other scripts running in different threads of the same process at the same time, changing the process-wide locale using setlocale().

You don't see this in a FastCGI setup because a new process is spawned for every page load. But in php-fpm a pool of processes is maintained indefinitely.

To resolve the problem, ideally each customer should have their own php-fpm pool. Then the customer is responsible for any applications they run which don't properly set the locale when they start up.

1
  • Thanks. Each customer alreay have their own php-fpm pool. Jun 3, 2015 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .