From 23f92effab048ccd69eeab6667f1b61b87283bbd Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 19 Dec 2019 11:03:25 -0800 Subject: [PATCH] Added configurable options for setting locales (#1069) #1063 --- Dockerfile-msphpsql | 12 +- azure-pipelines.yml | 10 +- source/pdo_sqlsrv/pdo_init.cpp | 16 +++ source/pdo_sqlsrv/php_pdo_sqlsrv.h | 4 + source/pdo_sqlsrv/php_pdo_sqlsrv_int.h | 8 ++ source/shared/core_init.cpp | 6 - source/sqlsrv/init.cpp | 19 ++++ source/sqlsrv/php_sqlsrv.h | 4 + source/sqlsrv/php_sqlsrv_int.h | 9 ++ .../pdo_sqlsrv/pdo_1063_locale_configs.phpt | 103 ++++++++++++++++++ .../pdo_sqlsrv/pdo_1063_test_locale.php | 61 +++++++++++ .../pdo_sqlsrv/skipif_unix_locales.inc | 29 +++++ test/functional/sqlsrv/TC34_PrepAndExec.phpt | 3 - test/functional/sqlsrv/TC42_FetchField.phpt | 3 - test/functional/sqlsrv/TC43_FetchData.phpt | 3 - test/functional/sqlsrv/TC44_FetchArray.phpt | 3 - test/functional/sqlsrv/TC45_FetchObject.phpt | 3 - .../sqlsrv/TC46_FetchNextResult.phpt | 3 - .../sqlsrv/TC48_FetchScrollable.phpt | 3 - test/functional/sqlsrv/TC51_StreamRead.phpt | 3 - .../sqlsrv/TC55_StreamScrollable.phpt | 3 - .../functional/sqlsrv/skipif_unix_locales.inc | 29 +++++ .../sqlsrv/srv_1063_locale_configs.phpt | 103 ++++++++++++++++++ .../sqlsrv/srv_1063_test_locale.php | 75 +++++++++++++ .../sqlsrv/test_stream_large_data.phpt | 3 - 25 files changed, 477 insertions(+), 41 deletions(-) create mode 100644 test/functional/pdo_sqlsrv/pdo_1063_locale_configs.phpt create mode 100644 test/functional/pdo_sqlsrv/pdo_1063_test_locale.php create mode 100644 test/functional/pdo_sqlsrv/skipif_unix_locales.inc create mode 100644 test/functional/sqlsrv/skipif_unix_locales.inc create mode 100644 test/functional/sqlsrv/srv_1063_locale_configs.phpt create mode 100644 test/functional/sqlsrv/srv_1063_test_locale.php diff --git a/Dockerfile-msphpsql b/Dockerfile-msphpsql index 4960b584..512d3cf5 100644 --- a/Dockerfile-msphpsql +++ b/Dockerfile-msphpsql @@ -39,12 +39,14 @@ ENV TEST_PHP_SQL_PWD Password123 # update PATH after ODBC driver and tools are installed ENV PATH="/opt/mssql-tools/bin:${PATH}" -# add locale iso-8859-1 +# add locales for testing RUN sed -i 's/# en_US ISO-8859-1/en_US ISO-8859-1/g' /etc/locale.gen -RUN locale-gen en_US +RUN sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen +RUN sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen +RUN locale-gen # set locale to utf-8 -RUN locale-gen en_US.UTF-8 +# RUN locale-gen en_US.UTF-8 ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' # install coveralls (upgrade both pip and requests first) @@ -65,6 +67,10 @@ RUN /bin/bash -c "./packagize.sh" RUN echo "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.3/mods-available/sqlsrv.ini RUN echo "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.3/mods-available/pdo_sqlsrv.ini +# create a writable ini file for testing locales +RUN echo '' > `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/99-overrides.ini +RUN chmod 666 `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/99-overrides.ini + WORKDIR $PHPSQLDIR/source/sqlsrv RUN /usr/bin/phpize && ./configure LDFLAGS="-lgcov" CXXFLAGS="-O0 --coverage" && make && make install diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6212ef3f..ef8f34b4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -107,8 +107,9 @@ jobs: - script: | sudo sed -i 's/# en_US ISO-8859-1/en_US ISO-8859-1/g' /etc/locale.gen - sudo locale-gen en_US - sudo locale-gen en_US.UTF-8 + sudo sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen + sudo sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen + sudo locale-gen export LANG='en_US.UTF-8' export LANGUAGE='en_US:en' export LC_ALL='en_US.UTF-8' @@ -151,6 +152,9 @@ jobs: echo copying pdo_sqlsrv to $dest sudo cp 30-pdo_sqlsrv.ini $dest + sudo touch $dest/99-overrides.ini + sudo chmod 666 $dest/99-overrides.ini + php --ri sqlsrv php --ri pdo_sqlsrv displayName: 'Build and install drivers' @@ -162,6 +166,7 @@ jobs: sed -i -e 's/TARGET_USERNAME/'"$(uid)"'/g' MsSetup.inc sed -i -e 's/TARGET_PASSWORD/'"$(pwd)"'/g' MsSetup.inc + export LC_ALL='en_US.UTF-8' php run-tests.php -P ./*.phpt 2>&1 | tee ../sqlsrv.log displayName: 'Run sqlsrv functional tests' @@ -172,6 +177,7 @@ jobs: sed -i -e 's/TARGET_USERNAME/'"$(uid)"'/g' MsSetup.inc sed -i -e 's/TARGET_PASSWORD/'"$(pwd)"'/g' MsSetup.inc + export LC_ALL='en_US.UTF-8' php run-tests.php -P ./*.phpt 2>&1 | tee ../pdo_sqlsrv.log displayName: 'Run pdo_sqlsrv functional tests' diff --git a/source/pdo_sqlsrv/pdo_init.cpp b/source/pdo_sqlsrv/pdo_init.cpp index 8f374093..de9f33ee 100644 --- a/source/pdo_sqlsrv/pdo_init.cpp +++ b/source/pdo_sqlsrv/pdo_init.cpp @@ -220,6 +220,22 @@ PHP_RINIT_FUNCTION(pdo_sqlsrv) ZEND_TSRMLS_CACHE_UPDATE(); #endif +#ifndef _WIN32 + // if necessary, set locale from the environment for ODBC, which MUST be done before any connection + int set_locale = PDO_SQLSRV_G(set_locale_info); + if (set_locale == 2) { + setlocale(LC_ALL, ""); + LOG(SEV_NOTICE, "pdo_sqlsrv: setlocale LC_ALL"); + } + else if (set_locale == 1) { + setlocale(LC_CTYPE, ""); + LOG(SEV_NOTICE, "pdo_sqlsrv: setlocale LC_CTYPE"); + } + else { + LOG(SEV_NOTICE, "pdo_sqlsrv: setlocale NONE"); + } +#endif + LOG( SEV_NOTICE, "pdo_sqlsrv: entering rinit" ); return SUCCESS; diff --git a/source/pdo_sqlsrv/php_pdo_sqlsrv.h b/source/pdo_sqlsrv/php_pdo_sqlsrv.h index a6403219..f3d13b85 100644 --- a/source/pdo_sqlsrv/php_pdo_sqlsrv.h +++ b/source/pdo_sqlsrv/php_pdo_sqlsrv.h @@ -32,6 +32,10 @@ ZEND_BEGIN_MODULE_GLOBALS(pdo_sqlsrv) unsigned int log_severity; zend_long client_buffer_max_size; +#ifndef _WIN32 +zend_long set_locale_info; +#endif + ZEND_END_MODULE_GLOBALS(pdo_sqlsrv) ZEND_EXTERN_MODULE_GLOBALS(pdo_sqlsrv); diff --git a/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h b/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h index 2b7269c0..2ddd3961 100644 --- a/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h +++ b/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h @@ -55,11 +55,19 @@ extern HMODULE g_sqlsrv_hmodule; #define INI_PDO_SQLSRV_LOG "log_severity" #define INI_PREFIX "pdo_sqlsrv." +#ifndef _WIN32 +#define INI_PDO_SET_LOCALE_INFO "set_locale_info" +#endif + PHP_INI_BEGIN() STD_PHP_INI_ENTRY( INI_PREFIX INI_PDO_SQLSRV_LOG , "0", PHP_INI_ALL, OnUpdateLong, log_severity, zend_pdo_sqlsrv_globals, pdo_sqlsrv_globals ) STD_PHP_INI_ENTRY( INI_PREFIX INI_PDO_SQLSRV_CLIENT_BUFFER_MAX_SIZE , INI_BUFFERED_QUERY_LIMIT_DEFAULT, PHP_INI_ALL, OnUpdateLong, client_buffer_max_size, zend_pdo_sqlsrv_globals, pdo_sqlsrv_globals ) +#ifndef _WIN32 + STD_PHP_INI_ENTRY(INI_PREFIX INI_PDO_SET_LOCALE_INFO, "2", PHP_INI_ALL, OnUpdateLong, set_locale_info, + zend_pdo_sqlsrv_globals, pdo_sqlsrv_globals) +#endif PHP_INI_END() diff --git a/source/shared/core_init.cpp b/source/shared/core_init.cpp index 63d08ce9..d2c386c9 100644 --- a/source/shared/core_init.cpp +++ b/source/shared/core_init.cpp @@ -39,12 +39,6 @@ void core_sqlsrv_minit( _Outptr_ sqlsrv_context** henv_cp, _Inout_ sqlsrv_contex SQLSRV_STATIC_ASSERT( sizeof( sqlsrv_sqltype ) == sizeof( zend_long ) ); SQLSRV_STATIC_ASSERT( sizeof( sqlsrv_phptype ) == sizeof( zend_long )); -#ifndef _WIN32 - // set locale from environment - // this is necessary for ODBC and MUST be done before connection - setlocale(LC_ALL, ""); -#endif - *henv_cp = *henv_ncp = SQL_NULL_HANDLE; // initialize return values to NULL try { diff --git a/source/sqlsrv/init.cpp b/source/sqlsrv/init.cpp index 2b394862..f12e23bb 100644 --- a/source/sqlsrv/init.cpp +++ b/source/sqlsrv/init.cpp @@ -654,6 +654,25 @@ PHP_RINIT_FUNCTION(sqlsrv) SQLSRV_G( log_subsystems ) = INI_INT( subsystems ); SQLSRV_G( buffered_query_limit ) = INI_INT( buffered_limit ); +#ifndef _WIN32 + char set_locale_info[] = INI_PREFIX INI_SET_LOCALE_INFO; + SQLSRV_G(set_locale_info) = INI_INT(set_locale_info); + + // if necessary, set locale from the environment for ODBC, which MUST be done before any connection + int set_locale = SQLSRV_G(set_locale_info); + if (set_locale == 2) { + setlocale(LC_ALL, ""); + } + else if (set_locale == 1) { + setlocale(LC_CTYPE, ""); + } + else { + // Do nothing + } + + LOG(SEV_NOTICE, INI_PREFIX INI_SET_LOCALE_INFO " = %1!d!", set_locale); +#endif + LOG( SEV_NOTICE, INI_PREFIX INI_WARNINGS_RETURN_AS_ERRORS " = %1!s!", SQLSRV_G( warnings_return_as_errors ) ? "On" : "Off"); LOG( SEV_NOTICE, INI_PREFIX INI_LOG_SEVERITY " = %1!d!", SQLSRV_G( log_severity )); LOG( SEV_NOTICE, INI_PREFIX INI_LOG_SUBSYSTEMS " = %1!d!", SQLSRV_G( log_subsystems )); diff --git a/source/sqlsrv/php_sqlsrv.h b/source/sqlsrv/php_sqlsrv.h index 36bb9a95..01a19b39 100644 --- a/source/sqlsrv/php_sqlsrv.h +++ b/source/sqlsrv/php_sqlsrv.h @@ -42,6 +42,10 @@ zend_long current_subsystem; zend_bool warnings_return_as_errors; zend_long buffered_query_limit; +#ifndef _WIN32 +zend_long set_locale_info; +#endif + ZEND_END_MODULE_GLOBALS(sqlsrv) ZEND_EXTERN_MODULE_GLOBALS(sqlsrv); diff --git a/source/sqlsrv/php_sqlsrv_int.h b/source/sqlsrv/php_sqlsrv_int.h index 42148b03..1866e37b 100644 --- a/source/sqlsrv/php_sqlsrv_int.h +++ b/source/sqlsrv/php_sqlsrv_int.h @@ -37,6 +37,10 @@ #define INI_BUFFERED_QUERY_LIMIT "ClientBufferMaxKBSize" #define INI_PREFIX "sqlsrv." +#ifndef _WIN32 +#define INI_SET_LOCALE_INFO "SetLocaleInfo" +#endif + PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN( INI_PREFIX INI_WARNINGS_RETURN_AS_ERRORS , "1", PHP_INI_ALL, OnUpdateBool, warnings_return_as_errors, zend_sqlsrv_globals, sqlsrv_globals ) @@ -46,6 +50,11 @@ PHP_INI_BEGIN() sqlsrv_globals ) STD_PHP_INI_ENTRY( INI_PREFIX INI_BUFFERED_QUERY_LIMIT, INI_BUFFERED_QUERY_LIMIT_DEFAULT, PHP_INI_ALL, OnUpdateLong, buffered_query_limit, zend_sqlsrv_globals, sqlsrv_globals ) +#ifndef _WIN32 + STD_PHP_INI_ENTRY(INI_PREFIX INI_SET_LOCALE_INFO, "2", PHP_INI_ALL, OnUpdateLong, set_locale_info, + zend_sqlsrv_globals, sqlsrv_globals) +#endif + PHP_INI_END() diff --git a/test/functional/pdo_sqlsrv/pdo_1063_locale_configs.phpt b/test/functional/pdo_sqlsrv/pdo_1063_locale_configs.phpt new file mode 100644 index 00000000..8d4fa73b --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_1063_locale_configs.phpt @@ -0,0 +1,103 @@ +--TEST-- +GitHub issue 1063 - make setting locale info configurable +--DESCRIPTION-- +This test verifies that the users can configure using ini file to set application locale using the system locale or not. This test is valid for Linux and macOS systems only. +--ENV-- +PHPT_EXEC=true +--SKIPIF-- + +--FILE-- + $file"); + print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/pdo_1063_test_locale.php ")); + print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/pdo_1063_test_locale.php $locale")); +} + +$inifile = PHP_CONFIG_FILE_SCAN_DIR."/99-overrides.ini"; + +$locale1 = strtoupper(PHP_OS) === 'LINUX' ? "en_US.ISO-8859-1" : "en_US.ISO8859-1"; +$locale2 = 'de_DE.UTF-8'; + +runTest(0, $inifile, $locale1); +runTest(1, $inifile, $locale2); +runTest(2, $inifile, $locale2); +?> +--EXPECT-- + +***sqlsrv.SetLocaleInfo = 0 +pdo_sqlsrv.set_locale_info = 0*** + +**Begin** +Current LC_MONETARY: C +Current LC_CTYPE: en_US.UTF-8 +Currency symbol: +Thousands_sep: +Amount formatted: 10000.99 +Friday +December +3.14159 +**End** +**Begin** +Current LC_MONETARY: C +Current LC_CTYPE: en_US.UTF-8 +Setting LC_ALL: en_US.ISO-8859-1 +Currency symbol: $ +Thousands_sep: , +Amount formatted: USD 10,000.99 +Friday +December +3.14159 +**End** + +***sqlsrv.SetLocaleInfo = 1 +pdo_sqlsrv.set_locale_info = 1*** + +**Begin** +Current LC_MONETARY: C +Current LC_CTYPE: en_US.UTF-8 +Currency symbol: +Thousands_sep: +Amount formatted: 10000.99 +Friday +December +3.14159 +**End** +**Begin** +Current LC_MONETARY: C +Current LC_CTYPE: en_US.UTF-8 +Setting LC_ALL: de_DE.UTF-8 +Currency symbol: € +Thousands_sep: . +Amount formatted: 10.000,99 EUR +Freitag +Dezember +3,14159 +**End** + +***sqlsrv.SetLocaleInfo = 2 +pdo_sqlsrv.set_locale_info = 2*** + +**Begin** +Current LC_MONETARY: en_US.UTF-8 +Current LC_CTYPE: en_US.UTF-8 +Currency symbol: $ +Thousands_sep: , +Amount formatted: USD 10,000.99 +Friday +December +3.14159 +**End** +**Begin** +Current LC_MONETARY: en_US.UTF-8 +Current LC_CTYPE: en_US.UTF-8 +Setting LC_ALL: de_DE.UTF-8 +Currency symbol: € +Thousands_sep: . +Amount formatted: 10.000,99 EUR +Freitag +Dezember +3,14159 +**End** diff --git a/test/functional/pdo_sqlsrv/pdo_1063_test_locale.php b/test/functional/pdo_sqlsrv/pdo_1063_test_locale.php new file mode 100644 index 00000000..b789d050 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_1063_test_locale.php @@ -0,0 +1,61 @@ +exec($tsql); +} + + +// This test is invoked by pdo_1063_locale_configs.phpt +require_once('MsSetup.inc'); + +$locale = ($_SERVER['argv'][1] ?? ''); + +echo "**Begin**" . PHP_EOL; +echo "Current LC_MONETARY: " . setlocale(LC_MONETARY, 0) . PHP_EOL; +echo "Current LC_CTYPE: " . setlocale(LC_CTYPE, 0) . PHP_EOL; + +if (!empty($locale)) { + $loc = setlocale(LC_ALL, $locale); + echo "Setting LC_ALL: " . $loc . PHP_EOL; +} + +$info = localeconv(); +echo "Currency symbol: " . $info['currency_symbol'] . PHP_EOL; +echo "Thousands_sep: " . $info['thousands_sep'] . PHP_EOL; + +$n1 = 10000.98765; +echo "Amount formatted: " . money_format("%i", $n1) . PHP_EOL; +echo strftime("%A", strtotime("12/25/2020")) . PHP_EOL; +echo strftime("%B", strtotime("12/25/2020")) . PHP_EOL; + +try { + $conn = new PDO("sqlsrv:server = $server; database=$databaseName; driver=$driver", $uid, $pwd ); + + $tableName = "[" . "pdo1063" . $locale . "]"; + + dropTable($conn, $tableName); + + $pi = "3.14159"; + + $stmt = $conn->query("CREATE TABLE $tableName (c1 FLOAT)"); + $stmt = $conn->query("INSERT INTO $tableName (c1) VALUES ($pi)"); + + $sql = "SELECT c1 FROM $tableName"; + $stmt = $conn->prepare($sql, array(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE => true)); + $stmt->execute(); + + $row = $stmt->fetch(PDO::FETCH_NUM); + echo ($row[0]) . PHP_EOL; + unset($stmt); + + dropTable($conn, $tableName); + + unset($conn); +} catch( PDOException $e ) { + print_r( $e->getMessage() ); +} + +echo "**End**" . PHP_EOL; +?> \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/skipif_unix_locales.inc b/test/functional/pdo_sqlsrv/skipif_unix_locales.inc new file mode 100644 index 00000000..5bf6eac2 --- /dev/null +++ b/test/functional/pdo_sqlsrv/skipif_unix_locales.inc @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index ae9365ca..6364f22f 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -7,9 +7,6 @@ Validates that a prepared statement can be successfully executed more than once. PHPT_EXEC=true --SKIPIF-- --FILE-- diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index 21240a66..01a4d993 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -7,9 +7,6 @@ retrieving fields from a table including rows with all supported SQL types (28 t PHPT_EXEC=true --SKIPIF-- --FILE-- diff --git a/test/functional/sqlsrv/TC43_FetchData.phpt b/test/functional/sqlsrv/TC43_FetchData.phpt index 023c77da..7228d2d4 100644 --- a/test/functional/sqlsrv/TC43_FetchData.phpt +++ b/test/functional/sqlsrv/TC43_FetchData.phpt @@ -4,9 +4,6 @@ Fetch Field Data Test verifies the data retrieved via sqlsrv_get_field PHPT_EXEC=true --SKIPIF-- --FILE-- diff --git a/test/functional/sqlsrv/TC44_FetchArray.phpt b/test/functional/sqlsrv/TC44_FetchArray.phpt index 0c7ce029..70a9366e 100644 --- a/test/functional/sqlsrv/TC44_FetchArray.phpt +++ b/test/functional/sqlsrv/TC44_FetchArray.phpt @@ -7,9 +7,6 @@ by checking all fetch type modes. PHPT_EXEC=true --SKIPIF-- --FILE-- diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index c5b9865b..589c4540 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -6,9 +6,6 @@ Verifies data retrieval via "sqlsrv_fetch_object". PHPT_EXEC=true --SKIPIF-- --FILE-- diff --git a/test/functional/sqlsrv/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index 4c3dc4bf..46c6d43b 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -6,9 +6,6 @@ Verifies the functionality of "sqlsrv_next_result" PHPT_EXEC=true --SKIPIF-- --FILE-- diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index 381ca6f6..84d15a7b 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -6,9 +6,6 @@ Verifies data retrieval with scrollable result sets. PHPT_EXEC=true --SKIPIF-- --FILE-- diff --git a/test/functional/sqlsrv/TC51_StreamRead.phpt b/test/functional/sqlsrv/TC51_StreamRead.phpt index dd9a0a43..1b6c834c 100644 --- a/test/functional/sqlsrv/TC51_StreamRead.phpt +++ b/test/functional/sqlsrv/TC51_StreamRead.phpt @@ -7,9 +7,6 @@ can be successfully retrieved as streams. PHPT_EXEC=true --SKIPIF-- --FILE-- diff --git a/test/functional/sqlsrv/TC55_StreamScrollable.phpt b/test/functional/sqlsrv/TC55_StreamScrollable.phpt index 99e97345..be4872ee 100644 --- a/test/functional/sqlsrv/TC55_StreamScrollable.phpt +++ b/test/functional/sqlsrv/TC55_StreamScrollable.phpt @@ -6,9 +6,6 @@ Verifies the streaming behavior with scrollable resultsets. PHPT_EXEC=true --SKIPIF-- --FILE-- diff --git a/test/functional/sqlsrv/skipif_unix_locales.inc b/test/functional/sqlsrv/skipif_unix_locales.inc new file mode 100644 index 00000000..5bf6eac2 --- /dev/null +++ b/test/functional/sqlsrv/skipif_unix_locales.inc @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/test/functional/sqlsrv/srv_1063_locale_configs.phpt b/test/functional/sqlsrv/srv_1063_locale_configs.phpt new file mode 100644 index 00000000..b3a26d6b --- /dev/null +++ b/test/functional/sqlsrv/srv_1063_locale_configs.phpt @@ -0,0 +1,103 @@ +--TEST-- +GitHub issue 1063 - make setting locale info configurable +--DESCRIPTION-- +This test verifies that the users can configure using ini file to set application locale using the system locale or not. This test is valid for Linux and macOS systems only. +--ENV-- +PHPT_EXEC=true +--SKIPIF-- + +--FILE-- + $file"); + print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/srv_1063_test_locale.php ")); + print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/srv_1063_test_locale.php $locale")); +} + +$inifile = PHP_CONFIG_FILE_SCAN_DIR."/99-overrides.ini"; + +$locale1 = strtoupper(PHP_OS) === 'LINUX' ? "en_US.ISO-8859-1" : "en_US.ISO8859-1"; +$locale2 = 'de_DE.UTF-8'; + +runTest(0, $inifile, $locale1); +runTest(1, $inifile, $locale2); +runTest(2, $inifile, $locale2); +?> +--EXPECT-- + +***sqlsrv.SetLocaleInfo = 0 +pdo_sqlsrv.set_locale_info = 0*** + +**Begin** +Current LC_MONETARY: C +Current LC_CTYPE: en_US.UTF-8 +Currency symbol: +Thousands_sep: +Amount formatted: 10000.99 +Friday +December +3.14159 +**End** +**Begin** +Current LC_MONETARY: C +Current LC_CTYPE: en_US.UTF-8 +Setting LC_ALL: en_US.ISO-8859-1 +Currency symbol: $ +Thousands_sep: , +Amount formatted: USD 10,000.99 +Friday +December +3.14159 +**End** + +***sqlsrv.SetLocaleInfo = 1 +pdo_sqlsrv.set_locale_info = 1*** + +**Begin** +Current LC_MONETARY: C +Current LC_CTYPE: en_US.UTF-8 +Currency symbol: +Thousands_sep: +Amount formatted: 10000.99 +Friday +December +3.14159 +**End** +**Begin** +Current LC_MONETARY: C +Current LC_CTYPE: en_US.UTF-8 +Setting LC_ALL: de_DE.UTF-8 +Currency symbol: € +Thousands_sep: . +Amount formatted: 10.000,99 EUR +Freitag +Dezember +3,14159 +**End** + +***sqlsrv.SetLocaleInfo = 2 +pdo_sqlsrv.set_locale_info = 2*** + +**Begin** +Current LC_MONETARY: en_US.UTF-8 +Current LC_CTYPE: en_US.UTF-8 +Currency symbol: $ +Thousands_sep: , +Amount formatted: USD 10,000.99 +Friday +December +3.14159 +**End** +**Begin** +Current LC_MONETARY: en_US.UTF-8 +Current LC_CTYPE: en_US.UTF-8 +Setting LC_ALL: de_DE.UTF-8 +Currency symbol: € +Thousands_sep: . +Amount formatted: 10.000,99 EUR +Freitag +Dezember +3,14159 +**End** diff --git a/test/functional/sqlsrv/srv_1063_test_locale.php b/test/functional/sqlsrv/srv_1063_test_locale.php new file mode 100644 index 00000000..fb9588b8 --- /dev/null +++ b/test/functional/sqlsrv/srv_1063_test_locale.php @@ -0,0 +1,75 @@ + \ No newline at end of file diff --git a/test/functional/sqlsrv/test_stream_large_data.phpt b/test/functional/sqlsrv/test_stream_large_data.phpt index eacf853a..414baa22 100644 --- a/test/functional/sqlsrv/test_stream_large_data.phpt +++ b/test/functional/sqlsrv/test_stream_large_data.phpt @@ -2,9 +2,6 @@ streaming large amounts of data into a database and getting it out as a string exactly the same. --SKIPIF-- --FILE--