Skip to content

[Bug]: Locale Variable Changes After PHP Update Cause Inconsistent Output #1282

@gr-leo-carmo

Description

@gr-leo-carmo

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions