[Bug]: Locale Variable Changes After PHP Update Cause Inconsistent Output
Platform
macOS
Operating system version
15.3 (24D60)
System architecture
ARM64 (M1, M2, etc)
Herd Version
1.14.1
PHP Version
Last Version of PHP 8.3.17 and 8.4.4
Bug description
After updating PHP to its latest versions (8.4.4 and 8.3.17), the default value of the locale variables changed. PHP started using the locale variables from the OSX operating system. In my case, this becomes a problem because the software I work with does not have the same locale settings as mine.
I know there are several ways to solve this through PHP code using setlocale, but the strange thing is that when I run the tests in PhpStorm, I still get the previous output(PHP 8.2.27).
Steps to reproduce
At terminal, when i run locale
I get the output below
LANG="pt_BR.UTF-8"
LC_COLLATE="pt_BR.UTF-8"
LC_CTYPE="pt_BR.UTF-8"
LC_MESSAGES="pt_BR.UTF-8"
LC_MONETARY="pt_BR.UTF-8"
LC_NUMERIC="pt_BR.UTF-8"
LC_TIME="pt_BR.UTF-8"
LC_ALL=
When i dump localeconv();
PHP 8.2.27
array:18 [
"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" => []
"mon_grouping" => []
]
PHP 8.3.17 and 8.4.4
array:18 [
"decimal_point" => ","
"thousands_sep" => "."
"int_curr_symbol" => "BRL "
"currency_symbol" => "R$"
"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:2 [
0 => 3
1 => 3
]
"mon_grouping" => array:2 [
0 => 3
1 => 3
]
]
Relevant log output
I've run into this too. You can reproduce this issue by running the following laravel/framework test locally using Herd.
vendor/bin/phpunit --filter wordCount
This assertion fails: https://github.com/laravel/framework/blob/abf823f36b5cb31b910cbbb14225dccfeeb52263/tests/Support/SupportStrTest.php#L1291
On earlier versions of PHP setlocale(LC_ALL, 0) returns C. On the latest versions it returns something like en_US.UTF-8.
This is a regression issue coming from the sqlsrv extension - the same error happens when installing PHP via Homebrew. As soon as sqlsrv is enabled, this error seems to occur.
I have created an issue in the upstream repository, hopefully this can be resolved soon
https://github.com/microsoft/msphpsql/issues/1532
Can someone provide a working reproducible example, for example via GitHub Action (where MacOS can be also used as OS)?
the same error happens when installing PHP via Homebrew.
Only in this case? I remember that homebrew downloaded the source tarball and afterwards compiled PHP on my Macbook, but that was 5 years ago.
Hi @DanielRuf I have posted a repo on the related issue for you.
@jasonvarga thanks, that helped.
I did some testing. So far: ✗ PHP 8.4.3 + SQLSRV 5.11.0: https://github.com/DanielRuf/msphpsql-issue/actions/runs/16838117510/job/47702465100 ✗ PHP 8.4.1 + SQLSRV 5.10.0: https://github.com/DanielRuf/msphpsql-issue/actions/runs/16838654593/job/47704238150
To me it seems this is unrelated to recent SQLSRV changes, at least the problem seems to be older. Unless I oversee something.
Due to https://github.com/shivammathur/setup-php/issues/687 I can not test against different patch versions of PHP < 8.4.
If possible, could anyone with an ARM Mac do some more testing? So far the same problem also exists on PHP 8.0. But that doesn't say anything about the exact versions of the libraries used in the affected PHP + SQLSRV binaries.
https://github.com/DanielRuf/msphpsql-issue/actions
Maybe something changed in PHP or MacOS? https://github.com/microsoft/msphpsql/issues/1532#issuecomment-3172980812
Anyways, someone should do some proper testing and show exactly, when this regression was introduced. Because if not, then this is not a regression by the SQLSRV extension.
I understand, that it still works in PHP 8.2.27, correct? If so, can someone check which exact PHP version introduced this?
Probably bug caused by changed locale settings in macos 15+ in PHP, see https://github.com/php/php-src/issues/19828 for more details.