From 6ad5c1e60dfc36764e6d4eabcbcfe4d30ca9e626 Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Thu, 9 May 2019 16:56:18 -0700 Subject: [PATCH 01/11] Added connection string flag --- source/shared/core_conn.cpp | 2 +- source/shared/core_sqlsrv.h | 2 +- source/shared/core_util.cpp | 20 +++++++++++++------- source/sqlsrv/php_sqlsrv_int.h | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/source/shared/core_conn.cpp b/source/shared/core_conn.cpp index 3d195fe9c..527143557 100644 --- a/source/shared/core_conn.cpp +++ b/source/shared/core_conn.cpp @@ -386,7 +386,7 @@ SQLRETURN core_odbc_connect( _Inout_ sqlsrv_conn* conn, _Inout_ std::string& con // We only support UTF-8 encoding for connection string. // Convert our UTF-8 connection string to UTF-16 before connecting with SQLDriverConnnectW - wconn_string = utf16_string_from_mbcs_string( SQLSRV_ENCODING_UTF8, conn_str.c_str(), static_cast( conn_str.length() ), &wconn_len ); + wconn_string = utf16_string_from_mbcs_string( SQLSRV_ENCODING_UTF8, conn_str.c_str(), static_cast( conn_str.length() ), &wconn_len, true ); CHECK_CUSTOM_ERROR( wconn_string == 0, conn, SQLSRV_ERROR_CONNECT_STRING_ENCODING_TRANSLATE, get_last_error_message()) { diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index b7a8c3921..08bc290f3 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -1808,7 +1808,7 @@ struct sqlsrv_buffered_result_set : public sqlsrv_result_set { bool convert_string_from_utf16_inplace( _In_ SQLSRV_ENCODING encoding, _Inout_updates_z_(len) char** string, _Inout_ SQLLEN& len); bool validate_string( _In_ char* string, _In_ SQLLEN& len); bool convert_string_from_utf16( _In_ SQLSRV_ENCODING encoding, _In_reads_bytes_(cchInLen) const SQLWCHAR* inString, _In_ SQLINTEGER cchInLen, _Inout_updates_bytes_(cchOutLen) char** outString, _Out_ SQLLEN& cchOutLen ); -SQLWCHAR* utf16_string_from_mbcs_string( _In_ SQLSRV_ENCODING php_encoding, _In_reads_bytes_(mbcs_len) const char* mbcs_string, _In_ unsigned int mbcs_len, _Out_ unsigned int* utf16_len ); +SQLWCHAR* utf16_string_from_mbcs_string( _In_ SQLSRV_ENCODING php_encoding, _In_reads_bytes_(mbcs_len) const char* mbcs_string, _In_ unsigned int mbcs_len, _Out_ unsigned int* utf16_len, bool is_connection_string = false ); //********************************************************************************************************************************* // Error handling routines and Predefined Errors diff --git a/source/shared/core_util.cpp b/source/shared/core_util.cpp index 8fea03358..acb53d015 100644 --- a/source/shared/core_util.cpp +++ b/source/shared/core_util.cpp @@ -34,7 +34,7 @@ char last_err_msg[2048] = {'\0'}; // 2k to hold the error messages unsigned int convert_string_from_default_encoding( _In_ unsigned int php_encoding, _In_reads_bytes_(mbcs_len) char const* mbcs_in_string, _In_ unsigned int mbcs_len, _Out_writes_(utf16_len) __transfer( mbcs_in_string ) SQLWCHAR* utf16_out_string, - _In_ unsigned int utf16_len ); + _In_ unsigned int utf16_len, bool is_connection_string = false ); } // SQLSTATE for all internal errors @@ -172,11 +172,11 @@ bool convert_string_from_utf16( _In_ SQLSRV_ENCODING encoding, _In_reads_bytes_( // allocation of the destination string. An empty string passed in returns // failure since it's a failure case for convert_string_from_default_encoding. SQLWCHAR* utf16_string_from_mbcs_string( _In_ SQLSRV_ENCODING php_encoding, _In_reads_bytes_(mbcs_len) const char* mbcs_string, _In_ unsigned int mbcs_len, - _Out_ unsigned int* utf16_len ) + _Out_ unsigned int* utf16_len, bool is_connection_string ) { *utf16_len = (mbcs_len + 1); SQLWCHAR* utf16_string = reinterpret_cast( sqlsrv_malloc( *utf16_len * sizeof( SQLWCHAR ))); - *utf16_len = convert_string_from_default_encoding( php_encoding, mbcs_string, mbcs_len, utf16_string, *utf16_len ); + *utf16_len = convert_string_from_default_encoding( php_encoding, mbcs_string, mbcs_len, utf16_string, *utf16_len, is_connection_string ); if( *utf16_len == 0 ) { // we preserve the error and reset it because sqlsrv_free resets the last error @@ -384,7 +384,7 @@ namespace { // to convert. unsigned int convert_string_from_default_encoding( _In_ unsigned int php_encoding, _In_reads_bytes_(mbcs_len) char const* mbcs_in_string, _In_ unsigned int mbcs_len, _Out_writes_(utf16_len) __transfer( mbcs_in_string ) SQLWCHAR* utf16_out_string, - _In_ unsigned int utf16_len ) + _In_ unsigned int utf16_len, bool is_connection_string ) { unsigned int win_encoding = CP_ACP; switch( php_encoding ) { @@ -399,8 +399,14 @@ unsigned int convert_string_from_default_encoding( _In_ unsigned int php_encodin win_encoding = php_encoding; break; } -#ifndef _WIN32 - unsigned int required_len = SystemLocale::ToUtf16( win_encoding, mbcs_in_string, mbcs_len, utf16_out_string, utf16_len ); +#ifndef _WIN32 + unsigned int required_len; + if (is_connection_string) { + required_len = SystemLocale::ToUtf16Strict( win_encoding, mbcs_in_string, mbcs_len, utf16_out_string, utf16_len ); + } + else { + required_len = SystemLocale::ToUtf16( win_encoding, mbcs_in_string, mbcs_len, utf16_out_string, utf16_len ); + } #else unsigned int required_len = MultiByteToWideChar( win_encoding, MB_ERR_INVALID_CHARS, mbcs_in_string, mbcs_len, utf16_out_string, utf16_len ); #endif // !_Win32 @@ -610,4 +616,4 @@ namespace data_classification { columns_sensitivity.clear(); } -} // namespace data_classification \ No newline at end of file +} // namespace data_classification diff --git a/source/sqlsrv/php_sqlsrv_int.h b/source/sqlsrv/php_sqlsrv_int.h index c294f465b..a12ff674d 100644 --- a/source/sqlsrv/php_sqlsrv_int.h +++ b/source/sqlsrv/php_sqlsrv_int.h @@ -214,12 +214,12 @@ bool ss_error_handler( _Inout_ sqlsrv_context& ctx, _In_ unsigned int sqlsrv_err // returned in utf16_out_string. unsigned int convert_string_from_default_encoding( _In_ unsigned int php_encoding, _In_reads_bytes_(mbcs_len) char const* mbcs_in_string, _In_ unsigned int mbcs_len, _Out_writes_(utf16_len) __transfer(mbcs_in_string) wchar_t* utf16_out_string, - _In_ unsigned int utf16_len ); + _In_ unsigned int utf16_len, bool is_connection_string = false ); // create a wide char string from the passed in mbcs string. NULL is returned if the string // could not be created. No error is posted by this function. utf16_len is the number of // wchar_t characters, not the number of bytes. SQLWCHAR* utf16_string_from_mbcs_string( _In_ unsigned int php_encoding, _In_reads_bytes_(mbcs_len) const char* mbcs_string, - _In_ unsigned int mbcs_len, _Out_ unsigned int* utf16_len ); + _In_ unsigned int mbcs_len, _Out_ unsigned int* utf16_len, bool is_connection_string = false ); // *** internal error macros and functions *** bool handle_error( sqlsrv_context const* ctx, int log_subsystem, const char* function, From aeeba5ca1da6798003a97223253f4f4feaf4ded2 Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Thu, 9 May 2019 16:58:35 -0700 Subject: [PATCH 02/11] Removed unix skipif --- test/functional/sqlsrv/sqlsrv_connStr.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/sqlsrv/sqlsrv_connStr.phpt b/test/functional/sqlsrv/sqlsrv_connStr.phpt index 144ceb94a..460ae391d 100644 --- a/test/functional/sqlsrv/sqlsrv_connStr.phpt +++ b/test/functional/sqlsrv/sqlsrv_connStr.phpt @@ -1,7 +1,7 @@ --TEST-- UTF-8 connection strings --SKIPIF-- - + --FILE-- Date: Thu, 9 May 2019 20:17:54 -0700 Subject: [PATCH 03/11] Fixed test output --- test/functional/sqlsrv/sqlsrv_connStr.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/sqlsrv/sqlsrv_connStr.phpt b/test/functional/sqlsrv/sqlsrv_connStr.phpt index 460ae391d..9d6d9b6fb 100644 --- a/test/functional/sqlsrv/sqlsrv_connStr.phpt +++ b/test/functional/sqlsrv/sqlsrv_connStr.phpt @@ -117,9 +117,9 @@ Array [SQLSTATE] => IMSSP [1] => -47 [code] => -47 - [2] => An error occurred translating the connection string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page. + [2] => An error occurred translating the connection string to UTF-16: %s - [message] => An error occurred translating the connection string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page. + [message] => An error occurred translating the connection string to UTF-16: %s ) From e031c1a3fa72f5d2749c2a6dda38d98fa507e86e Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Fri, 10 May 2019 12:56:51 -0700 Subject: [PATCH 04/11] Fixed pdo test --- test/functional/pdo_sqlsrv/pdo_construct_attr_errors.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/pdo_sqlsrv/pdo_construct_attr_errors.phpt b/test/functional/pdo_sqlsrv/pdo_construct_attr_errors.phpt index a31974d94..7b0f101a6 100644 --- a/test/functional/pdo_sqlsrv/pdo_construct_attr_errors.phpt +++ b/test/functional/pdo_sqlsrv/pdo_construct_attr_errors.phpt @@ -38,7 +38,7 @@ function invalidServer() echo "Should have failed to connect to invalid server.\n"; } catch (PDOException $e) { $error1 = '*Login timeout expired'; - $error2 = '*An error occurred translating the connection string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page*'; + $error2 = '*An error occurred translating the connection string to UTF-16: *'; if (fnmatch($error1, $e->getMessage()) || fnmatch($error2, $e->getMessage())) { ; // matched at least one of the expected error messages } else { @@ -102,7 +102,7 @@ function invalidPassword() $options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION); // Possible errors - $error = "*An error occurred translating the connection string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page.*"; + $error = "*An error occurred translating the connection string to UTF-16: *"; $error1 = "*Login failed for user \'*\'."; $error2 = "*Login timeout expired*"; From 9d9acc3627b96031c04a8afc6a8a0825d1e6e862 Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Fri, 10 May 2019 13:03:22 -0700 Subject: [PATCH 05/11] Changed flag name --- source/shared/core_sqlsrv.h | 2 +- source/shared/core_util.cpp | 10 +++++----- source/sqlsrv/php_sqlsrv_int.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index 08bc290f3..c6a0eb97a 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -1808,7 +1808,7 @@ struct sqlsrv_buffered_result_set : public sqlsrv_result_set { bool convert_string_from_utf16_inplace( _In_ SQLSRV_ENCODING encoding, _Inout_updates_z_(len) char** string, _Inout_ SQLLEN& len); bool validate_string( _In_ char* string, _In_ SQLLEN& len); bool convert_string_from_utf16( _In_ SQLSRV_ENCODING encoding, _In_reads_bytes_(cchInLen) const SQLWCHAR* inString, _In_ SQLINTEGER cchInLen, _Inout_updates_bytes_(cchOutLen) char** outString, _Out_ SQLLEN& cchOutLen ); -SQLWCHAR* utf16_string_from_mbcs_string( _In_ SQLSRV_ENCODING php_encoding, _In_reads_bytes_(mbcs_len) const char* mbcs_string, _In_ unsigned int mbcs_len, _Out_ unsigned int* utf16_len, bool is_connection_string = false ); +SQLWCHAR* utf16_string_from_mbcs_string( _In_ SQLSRV_ENCODING php_encoding, _In_reads_bytes_(mbcs_len) const char* mbcs_string, _In_ unsigned int mbcs_len, _Out_ unsigned int* utf16_len, bool use_strict_conversion = false ); //********************************************************************************************************************************* // Error handling routines and Predefined Errors diff --git a/source/shared/core_util.cpp b/source/shared/core_util.cpp index acb53d015..e5427f97a 100644 --- a/source/shared/core_util.cpp +++ b/source/shared/core_util.cpp @@ -34,7 +34,7 @@ char last_err_msg[2048] = {'\0'}; // 2k to hold the error messages unsigned int convert_string_from_default_encoding( _In_ unsigned int php_encoding, _In_reads_bytes_(mbcs_len) char const* mbcs_in_string, _In_ unsigned int mbcs_len, _Out_writes_(utf16_len) __transfer( mbcs_in_string ) SQLWCHAR* utf16_out_string, - _In_ unsigned int utf16_len, bool is_connection_string = false ); + _In_ unsigned int utf16_len, bool use_strict_conversion = false ); } // SQLSTATE for all internal errors @@ -172,11 +172,11 @@ bool convert_string_from_utf16( _In_ SQLSRV_ENCODING encoding, _In_reads_bytes_( // allocation of the destination string. An empty string passed in returns // failure since it's a failure case for convert_string_from_default_encoding. SQLWCHAR* utf16_string_from_mbcs_string( _In_ SQLSRV_ENCODING php_encoding, _In_reads_bytes_(mbcs_len) const char* mbcs_string, _In_ unsigned int mbcs_len, - _Out_ unsigned int* utf16_len, bool is_connection_string ) + _Out_ unsigned int* utf16_len, bool use_strict_conversion ) { *utf16_len = (mbcs_len + 1); SQLWCHAR* utf16_string = reinterpret_cast( sqlsrv_malloc( *utf16_len * sizeof( SQLWCHAR ))); - *utf16_len = convert_string_from_default_encoding( php_encoding, mbcs_string, mbcs_len, utf16_string, *utf16_len, is_connection_string ); + *utf16_len = convert_string_from_default_encoding( php_encoding, mbcs_string, mbcs_len, utf16_string, *utf16_len, use_strict_conversion ); if( *utf16_len == 0 ) { // we preserve the error and reset it because sqlsrv_free resets the last error @@ -384,7 +384,7 @@ namespace { // to convert. unsigned int convert_string_from_default_encoding( _In_ unsigned int php_encoding, _In_reads_bytes_(mbcs_len) char const* mbcs_in_string, _In_ unsigned int mbcs_len, _Out_writes_(utf16_len) __transfer( mbcs_in_string ) SQLWCHAR* utf16_out_string, - _In_ unsigned int utf16_len, bool is_connection_string ) + _In_ unsigned int utf16_len, bool use_strict_conversion ) { unsigned int win_encoding = CP_ACP; switch( php_encoding ) { @@ -401,7 +401,7 @@ unsigned int convert_string_from_default_encoding( _In_ unsigned int php_encodin } #ifndef _WIN32 unsigned int required_len; - if (is_connection_string) { + if (use_strict_conversion) { required_len = SystemLocale::ToUtf16Strict( win_encoding, mbcs_in_string, mbcs_len, utf16_out_string, utf16_len ); } else { diff --git a/source/sqlsrv/php_sqlsrv_int.h b/source/sqlsrv/php_sqlsrv_int.h index a12ff674d..bd555fe10 100644 --- a/source/sqlsrv/php_sqlsrv_int.h +++ b/source/sqlsrv/php_sqlsrv_int.h @@ -214,12 +214,12 @@ bool ss_error_handler( _Inout_ sqlsrv_context& ctx, _In_ unsigned int sqlsrv_err // returned in utf16_out_string. unsigned int convert_string_from_default_encoding( _In_ unsigned int php_encoding, _In_reads_bytes_(mbcs_len) char const* mbcs_in_string, _In_ unsigned int mbcs_len, _Out_writes_(utf16_len) __transfer(mbcs_in_string) wchar_t* utf16_out_string, - _In_ unsigned int utf16_len, bool is_connection_string = false ); + _In_ unsigned int utf16_len, bool use_strict_conversion = false ); // create a wide char string from the passed in mbcs string. NULL is returned if the string // could not be created. No error is posted by this function. utf16_len is the number of // wchar_t characters, not the number of bytes. SQLWCHAR* utf16_string_from_mbcs_string( _In_ unsigned int php_encoding, _In_reads_bytes_(mbcs_len) const char* mbcs_string, - _In_ unsigned int mbcs_len, _Out_ unsigned int* utf16_len, bool is_connection_string = false ); + _In_ unsigned int mbcs_len, _Out_ unsigned int* utf16_len, bool use_strict_conversion = false ); // *** internal error macros and functions *** bool handle_error( sqlsrv_context const* ctx, int log_subsystem, const char* function, From ca6d6cbb8ad4db52f1c8309831a1031ef4edfadf Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Fri, 10 May 2019 15:02:45 -0700 Subject: [PATCH 06/11] Fixed test output --- test/functional/sqlsrv/sqlsrv_connStr.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/sqlsrv/sqlsrv_connStr.phpt b/test/functional/sqlsrv/sqlsrv_connStr.phpt index 9d6d9b6fb..34ace5781 100644 --- a/test/functional/sqlsrv/sqlsrv_connStr.phpt +++ b/test/functional/sqlsrv/sqlsrv_connStr.phpt @@ -155,9 +155,9 @@ Array [SQLSTATE] => IMSSP [1] => -47 [code] => -47 - [2] => An error occurred translating the connection string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page. + [2] => An error occurred translating the connection string to UTF-16: %s - [message] => An error occurred translating the connection string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page. + [message] => An error occurred translating the connection string to UTF-16: %s ) From 209c4fdad08bd4255b8255a06ab4c8d6428c5c01 Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Fri, 10 May 2019 16:05:05 -0700 Subject: [PATCH 07/11] Fixed test output (again) --- test/functional/sqlsrv/sqlsrv_connStr.phpt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/functional/sqlsrv/sqlsrv_connStr.phpt b/test/functional/sqlsrv/sqlsrv_connStr.phpt index 34ace5781..9f6924ebe 100644 --- a/test/functional/sqlsrv/sqlsrv_connStr.phpt +++ b/test/functional/sqlsrv/sqlsrv_connStr.phpt @@ -118,9 +118,7 @@ Array [1] => -47 [code] => -47 [2] => An error occurred translating the connection string to UTF-16: %s - [message] => An error occurred translating the connection string to UTF-16: %s - ) ) @@ -156,9 +154,7 @@ Array [1] => -47 [code] => -47 [2] => An error occurred translating the connection string to UTF-16: %s - [message] => An error occurred translating the connection string to UTF-16: %s - ) ) From 50ba3244da237742faad6d5077e844d1ff25f8dd Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Fri, 10 May 2019 16:35:22 -0700 Subject: [PATCH 08/11] Fixed test output (again) --- test/functional/sqlsrv/sqlsrv_connStr.phpt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/functional/sqlsrv/sqlsrv_connStr.phpt b/test/functional/sqlsrv/sqlsrv_connStr.phpt index 9f6924ebe..779613d16 100644 --- a/test/functional/sqlsrv/sqlsrv_connStr.phpt +++ b/test/functional/sqlsrv/sqlsrv_connStr.phpt @@ -134,16 +134,6 @@ Array [message] => %SLogin failed for user '%s'. ) - [1] => Array - ( - [0] => 28000 - [SQLSTATE] => 28000 - [1] => 18456 - [code] => 18456 - [2] => %SLogin failed for user '%s'. - [message] => %SLogin failed for user '%s'. - ) - ) Array ( From 39c57af2b663f8c1734a47aa0e97a276b1096e32 Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Fri, 10 May 2019 16:56:45 -0700 Subject: [PATCH 09/11] Fixed test output (again) --- test/functional/sqlsrv/sqlsrv_connStr.phpt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functional/sqlsrv/sqlsrv_connStr.phpt b/test/functional/sqlsrv/sqlsrv_connStr.phpt index 779613d16..3c5d7934a 100644 --- a/test/functional/sqlsrv/sqlsrv_connStr.phpt +++ b/test/functional/sqlsrv/sqlsrv_connStr.phpt @@ -67,7 +67,8 @@ $c = connect(array( if ($c !== false) { fatalError("sqlsrv_connect(3) should have failed"); } -print_r(sqlsrv_errors()); +// On Windows, two errors are returned, with the same content. So just check the first one. +print_r(sqlsrv_errors()[0]); // invalid UTF-8 in the pwd $c = connect(array( From 69759676419b460a61d5bb9b24ec10107bb8a966 Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Fri, 10 May 2019 22:16:46 -0700 Subject: [PATCH 10/11] Replaced expected test output altogether --- test/functional/sqlsrv/sqlsrv_connStr.phpt | 94 ++++++---------------- 1 file changed, 23 insertions(+), 71 deletions(-) diff --git a/test/functional/sqlsrv/sqlsrv_connStr.phpt b/test/functional/sqlsrv/sqlsrv_connStr.phpt index 3c5d7934a..7629e3c7c 100644 --- a/test/functional/sqlsrv/sqlsrv_connStr.phpt +++ b/test/functional/sqlsrv/sqlsrv_connStr.phpt @@ -6,6 +6,13 @@ UTF-8 connection strings 'gibberish' )); if ($c !== false) { fatalError("Should have errored on an invalid encoding."); } -print_r(sqlsrv_errors()); +checkErrors($gibberishEncoding); $c = connect(array( 'CharacterSet' => SQLSRV_ENC_BINARY )); if ($c !== false) { fatalError("Should have errored on an invalid encoding."); } -print_r(sqlsrv_errors()); +checkErrors($binaryEncoding); $c = connect(array( 'CharacterSet' => SQLSRV_ENC_CHAR )); if ($c === false) { @@ -50,7 +68,7 @@ $c = sqlsrv_connect($server_invalid, array( 'Database' => 'test', 'CharacterSet' if ($c !== false) { fatalError("sqlsrv_connect(1) should have failed"); } -print_r(sqlsrv_errors()); +checkErrors($utf16Error); // APP has a UTF-8 name $c = connect(array( @@ -67,8 +85,7 @@ $c = connect(array( if ($c !== false) { fatalError("sqlsrv_connect(3) should have failed"); } -// On Windows, two errors are returned, with the same content. So just check the first one. -print_r(sqlsrv_errors()[0]); +checkErrors($userLoginFailed); // invalid UTF-8 in the pwd $c = connect(array( @@ -78,75 +95,10 @@ $c = connect(array( if ($c !== false) { fatalError("sqlsrv_connect(4) should have failed"); } -print_r(sqlsrv_errors()); +checkErrors($utf16Error); echo "Test succeeded.\n"; ?> --EXPECTF-- -Array -( - [0] => Array - ( - [0] => IMSSP - [SQLSTATE] => IMSSP - [1] => -48 - [code] => -48 - [2] => The encoding 'gibberish' is not a supported encoding for the CharacterSet connection option. - [message] => The encoding 'gibberish' is not a supported encoding for the CharacterSet connection option. - ) - -) -Array -( - [0] => Array - ( - [0] => IMSSP - [SQLSTATE] => IMSSP - [1] => -48 - [code] => -48 - [2] => The encoding 'binary' is not a supported encoding for the CharacterSet connection option. - [message] => The encoding 'binary' is not a supported encoding for the CharacterSet connection option. - ) - -) -Array -( - [0] => Array - ( - [0] => IMSSP - [SQLSTATE] => IMSSP - [1] => -47 - [code] => -47 - [2] => An error occurred translating the connection string to UTF-16: %s - [message] => An error occurred translating the connection string to UTF-16: %s - ) - -) -Array -( - [0] => Array - ( - [0] => 28000 - [SQLSTATE] => 28000 - [1] => 18456 - [code] => 18456 - [2] => %SLogin failed for user '%s'. - [message] => %SLogin failed for user '%s'. - ) - -) -Array -( - [0] => Array - ( - [0] => IMSSP - [SQLSTATE] => IMSSP - [1] => -47 - [code] => -47 - [2] => An error occurred translating the connection string to UTF-16: %s - [message] => An error occurred translating the connection string to UTF-16: %s - ) - -) Test succeeded. From 60f20bd1ea1bb710470170a13fe536f078691edd Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Mon, 13 May 2019 11:15:49 -0700 Subject: [PATCH 11/11] Replaced EXPECTF with EXPECT --- test/functional/sqlsrv/sqlsrv_connStr.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/sqlsrv/sqlsrv_connStr.phpt b/test/functional/sqlsrv/sqlsrv_connStr.phpt index 7629e3c7c..7c92bd997 100644 --- a/test/functional/sqlsrv/sqlsrv_connStr.phpt +++ b/test/functional/sqlsrv/sqlsrv_connStr.phpt @@ -100,5 +100,5 @@ checkErrors($utf16Error); echo "Test succeeded.\n"; ?> ---EXPECTF-- +--EXPECT-- Test succeeded.