msphpsql: sqlsrv extension modifies the locale settings and possibly breaks other software
+## PHP Driver version or file name ExtensionVer => 5.6.1 +## SQL Server version not relevant +## Client operating system Debian 10 +## PHP version 7.1.33 +## Microsoft ODBC Driver version not relevant +## Table schema not relevant +## Problem description The PHP Extension seems to override the LC_ options. This triggered a Problem in Magento 1 Shops. All prices were printed way to high. But this is not a fault of magento. I dont think a PHP extension should modify the locale settings at all.
Testing the output of localeconv with sqlsrv enabled:
/opt/php-7.1/bin/php -r "print_r(localeconv());"
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
[1] => 3
)
[mon_grouping] => Array
(
[0] => 3
[1] => 3
)
)
Testing the output of localeconv with sqlsrv disabled :
/opt/php-7.1/bin/php -r "print_r(localeconv());"
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
(
)
)
+## Expected behavior and actual behavior
- The extension should not modify locale config
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 18 (9 by maintainers)
Commits related to this issue
- Added configurable options for setting locales (#1069) #1063 — committed to microsoft/msphpsql by yitam 5 years ago
- 5.8.0 RTW dev to master (#1087) * Fixed the potential error reported by Prefast code analysis * Use SQLSRV_ASSERT for checking NULL ptrs * For these AKV tests check env despite not AE connected... — committed to microsoft/msphpsql by david-puglielli 4 years ago
@yitam Thank you 😃 it was really a problem related to pdo_sqlsrv. After setting
pdo_sqlsrv.set_locale_info = 0in my php.ini file everything works like a charm.Sorry for the fuss. You rock 👍
Hi @marvinhinz @naitsirch
We just released 5.8.0 and please check the latest documentation concerning this issue
hi @naitsirch , you can find it here
We will discuss how / whether to make this configurable, but in order not to introduce a breaking change the default might likely be the way it is now.
@yitam but this behaviour has some very unexpected and hard to debug side effects, which breaks other code. This should not happen.
As you know,
setlocale(LC_ALL, 0)can be used to retrieve the current locale settings. With sqlserv extension loaded, we get this output:Without the extension the output looks quite different:
And as @marvinhinz has already pointed out, Magento (version 1) that uses the Zend Framework’s locale component (see https://framework.zend.com/manual/1.12/en/zend.locale.functions.html) struggels with the setting done by sqlsrv extension.
Can you tell me, why the extension changes the locale settings?
HI @marvinhinz
It’s because the driver currently sets the application locale to the system one, which in your case is
de_DE.UTF-8. In other words, the driver essentially does this:php -r "setlocale(LC_ALL, ''); print_r(localeconv());"