diff --git a/Dockerfile-msphpsql b/Dockerfile-msphpsql index 477740a0..7d5f6585 100644 --- a/Dockerfile-msphpsql +++ b/Dockerfile-msphpsql @@ -45,6 +45,8 @@ RUN sed -i 's/# en_US ISO-8859-1/en_US ISO-8859-1/g' /etc/locale.gen RUN sed -i 's/# fr_FR@euro ISO-8859-15/fr_FR@euro ISO-8859-15/g' /etc/locale.gen 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 sed -i 's/# zh_CN GB2312/zh_CN GB2312/g' /etc/locale.gen +RUN sed -i 's/# zh_CN.GB18030 GB18030/zh_CN.GB18030 GB18030/g' /etc/locale.gen RUN locale-gen # set locale to utf-8 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 23579eab..6f7f2185 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -114,6 +114,8 @@ jobs: sudo sed -i 's/# fr_FR@euro ISO-8859-15/fr_FR@euro ISO-8859-15/g' /etc/locale.gen 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 sed -i 's/# zh_CN GB2312/zh_CN GB2312/g' /etc/locale.gen + sudo sed -i 's/# zh_CN.GB18030 GB18030/zh_CN.GB18030 GB18030/g' /etc/locale.gen sudo locale-gen export LANG='en_US.UTF-8' export LANGUAGE='en_US:en' diff --git a/test/functional/pdo_sqlsrv/pdo_ansi_locale_zh.phpt b/test/functional/pdo_sqlsrv/pdo_ansi_locale_zh.phpt index cbdcb739..6500a0cd 100644 --- a/test/functional/pdo_sqlsrv/pdo_ansi_locale_zh.phpt +++ b/test/functional/pdo_sqlsrv/pdo_ansi_locale_zh.phpt @@ -1,8 +1,8 @@ --TEST-- Test Chinese locale in Linux --DESCRIPTION-- -This test will invoke another php scirpt that is saved as GB2312(Simplified Chinese) ANSI format, -namely pdo_test_gb18030.php. +This test requires ODBC Driver 17.6 or above and will invoke another php script that +is saved as GB2312(Simplified Chinese) ANSI format, namely pdo_test_gb18030.php. To run this test, create a temporary database first with the correct collation CREATE DATABASE [GB18030test] COLLATE Chinese_PRC_CI_AS @@ -19,6 +19,28 @@ $loc = setlocale(LC_ALL, 'zh_CN.gb18030'); if (empty($loc)) { die("skip required gb18030 locale not available"); } + +require_once('MsSetup.inc'); +try { + $conn = new PDO("sqlsrv:server=$server", $uid, $pwd); + $msodbcsqlVer = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)['DriverVer']; + $version = explode(".", $msodbcsqlVer); + + $msodbcsqlMaj = $version[0]; + $msodbcsqlMin = $version[1]; + + if ($msodbcsqlMaj < 17) { + die("skip Unsupported ODBC driver version"); + } + + if ($msodbcsqlMaj == 17 && $msodbcsqlMin < 6) { + die("skip Unsupported ODBC driver version"); + } +} catch (PDOException $e) { + die("skip Something went wrong during SKIPIF."); +} +?> + --FILE-- getMessage() . PHP_EOL; } finally { - $query = "DROP DATABASE $tempDB"; - $conn->exec($query); - unset($conn); + if ($conn) { + $query = "DROP DATABASE $tempDB"; + $conn->exec($query); + unset($conn); + } } ?> diff --git a/test/functional/sqlsrv/sqlsrv_ansi_locale_zh.phpt b/test/functional/sqlsrv/sqlsrv_ansi_locale_zh.phpt index 5b8b911c..bfbee8b2 100644 --- a/test/functional/sqlsrv/sqlsrv_ansi_locale_zh.phpt +++ b/test/functional/sqlsrv/sqlsrv_ansi_locale_zh.phpt @@ -1,8 +1,8 @@ --TEST-- Test Chinese locale in Linux --DESCRIPTION-- -This test will invoke another php scirpt that is saved as GB2312(Simplified Chinese) ANSI format, -namely sqlsrv_test_gb18030.php. +This test requires ODBC Driver 17.6 or above and will invoke another php script that +is saved as GB2312(Simplified Chinese) ANSI format, namely sqlsrv_test_gb18030.php. To run this test, create a temporary database first with the correct collation CREATE DATABASE [GB18030test] COLLATE Chinese_PRC_CI_AS @@ -14,41 +14,67 @@ Drop the temporary database when the test is finished. PHPT_EXEC=true --SKIPIF-- $userName, "PWD"=>$userPassword); +$conn = sqlsrv_connect($server, $connectionInfo); +if ($conn === false) { + die("skip Could not connect during SKIPIF."); +} + +$msodbcsqlVer = sqlsrv_client_info($conn)["DriverVer"]; +$msodbcsqlMaj = explode(".", $msodbcsqlVer)[0]; +$msodbcsqlMin = explode(".", $msodbcsqlVer)[1]; + +if ($msodbcsqlMaj < 17) { + die("skip Unsupported ODBC driver version"); +} + +if ($msodbcsqlMaj == 17 && $msodbcsqlMin < 6) { + die("skip Unsupported ODBC driver version"); +} +?> + --FILE-- "master", "UID"=>$userName, "PWD"=>$userPassword); $conn = sqlsrv_connect($server, $options); if( $conn === false ) { - die(print_r(sqlsrv_errors(), true)); + throw new Error("Failed to connect"); } $tempDB = 'GB18030test' . rand(1, 100); $query = "CREATE DATABASE $tempDB COLLATE Chinese_PRC_CI_AS"; $stmt = sqlsrv_query($conn, $query); if ($stmt === false) { - echo "Failed to create the database $tempDB\n"; + throw new Error("Failed to create the database $tempDB"); } shell_exec("export LC_ALL=zh_CN.gb18030"); shell_exec("iconv -c -f GB2312 -t GB18030 sqlsrv_test_gb18030.php > test_gb18030.php"); - - print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/test_gb18030.php $tempDB")); - - $query = "DROP DATABASE $tempDB"; - sqlsrv_query($conn, $query); - sqlsrv_close($conn); -} -runTest(); + print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/test_gb18030.php $tempDB")); +} catch (Error $err) { + echo $err->getMessage() . PHP_EOL; + print_r(sqlsrv_errors()); +} finally { + if ($conn) { + if (!empty($tempDB)) { + $query = "DROP DATABASE $tempDB"; + sqlsrv_query($conn, $query); + } + sqlsrv_close($conn); + } +} ?> --EXPECT--