From 928be6d37180379033e26a8d2206a7961df02b0b Mon Sep 17 00:00:00 2001 From: Meet Bhagdev Date: Mon, 24 Oct 2016 16:11:52 -0700 Subject: [PATCH] 4.1.4 Release --- README.md | 5 +++++ pdo_sqlsrv/core_sqlsrv.h | 2 +- pdo_sqlsrv/core_util.cpp | 4 ++-- pdo_sqlsrv/pdo_util.cpp | 22 ++++++++-------------- pdo_sqlsrv/php_pdo_sqlsrv.h | 2 +- pdo_sqlsrv/template.rc | 10 +++++----- pdo_sqlsrv/version.h | 16 ++++++++++++---- sqlsrv/conn.cpp | 2 +- sqlsrv/core_sqlsrv.h | 2 +- sqlsrv/core_util.cpp | 4 ++-- sqlsrv/stmt.cpp | 24 ++++++++++++------------ sqlsrv/template.rc | 10 +++++----- sqlsrv/version.h | 16 ++++++++++++---- 13 files changed, 67 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 9afd8eb4..56093bb3 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,11 @@ The Microsoft Drivers for PHP for SQL Server Team ##Announcements +**October 25 , 2016** : Updated Windows drivers (4.1.4) compiled with PHP 7.0.12 and 7.1 are available. Here is the list of updates: + +- Drivers versioning has been redesigned as Major#.Minor#.Release#.Build#. Build number is specific to binaries and it doesn't match with the number on the source. +- Fixed the issue with duplicate warning messages in PDO_SQLSRV drivers when error mode is set to PDO::ERRMODE_WARNING. + **October 4 , 2016** : Updated Windows drivers (4.1.3) compiled with PHP 7.0.11 and 7.1.0RC3 are available. Here is the list of updates: - Fixed [issue #139](https://github.com/Microsoft/msphpsql/issues/139) : sqlsrv_fetch_object calls custom class constructor in static context and outputs an error. diff --git a/pdo_sqlsrv/core_sqlsrv.h b/pdo_sqlsrv/core_sqlsrv.h index d91a050a..1004c234 100644 --- a/pdo_sqlsrv/core_sqlsrv.h +++ b/pdo_sqlsrv/core_sqlsrv.h @@ -1612,7 +1612,7 @@ void core_sqlsrv_format_driver_error( sqlsrv_context& ctx, sqlsrv_error_const co const char* get_last_error_message( DWORD last_error = 0 ); // a wrapper around FormatMessage that can take variadic args rather than a a va_arg pointer -DWORD core_sqlsrv_format_message( char*& output_buffer, unsigned output_len, const char* format, ... ); +DWORD core_sqlsrv_format_message( char* output_buffer, unsigned output_len, const char* format, ... ); // convenience functions that overload either a reference or a pointer so we can use // either in the CHECK_* functions. diff --git a/pdo_sqlsrv/core_util.cpp b/pdo_sqlsrv/core_util.cpp index 7e12d520..fe3c4d06 100644 --- a/pdo_sqlsrv/core_util.cpp +++ b/pdo_sqlsrv/core_util.cpp @@ -306,12 +306,12 @@ void core_sqlsrv_format_driver_error( sqlsrv_context& ctx, sqlsrv_error_const co LOG( severity, "%1!s!: message = %2!s!", ctx.func(), formatted_error->native_message ); } -DWORD core_sqlsrv_format_message( char*& output_buffer, unsigned output_len, const char* format, ... ) +DWORD core_sqlsrv_format_message( char* output_buffer, unsigned output_len, const char* format, ... ) { va_list format_args; va_start( format_args, format ); - DWORD rc = FormatMessage( FORMAT_MESSAGE_FROM_STRING, format, 0, 0, static_cast(output_buffer), SQL_MAX_MESSAGE_LENGTH, &format_args ); + DWORD rc = FormatMessage( FORMAT_MESSAGE_FROM_STRING, format, 0, 0, static_cast(output_buffer), output_len, &format_args ); va_end( format_args ); diff --git a/pdo_sqlsrv/pdo_util.cpp b/pdo_sqlsrv/pdo_util.cpp index 89843b66..9c4bb631 100644 --- a/pdo_sqlsrv/pdo_util.cpp +++ b/pdo_sqlsrv/pdo_util.cpp @@ -25,13 +25,16 @@ // *** internal constants *** namespace { -const char WARNING_TEMPLATE[] = "SQLSTATE: %1!s!\nError Code: %2!d!\nMError Message: %3!s!\n"; +const char WARNING_TEMPLATE[] = "SQLSTATE: %1!s!\nError Code: %2!d!\nError Message: %3!s!\n"; const char EXCEPTION_MSG_TEMPLATE[] = "SQLSTATE[%s]: %s"; char EXCEPTION_PROPERTY_MSG[] = "message"; char EXCEPTION_PROPERTY_CODE[] = "code"; char EXCEPTION_PROPERTY_ERRORINFO[] = "errorInfo"; const int MAX_DIGITS = 11; // +-2 billion = 10 digits + 1 for the sign if negative +// the warning message is not the error message alone; it must take WARNING_TEMPLATE above into consideration without the formats +const int WARNING_MIN_LENGTH = strlen(WARNING_TEMPLATE) - strlen("%1!s!%2!d!%3!s!"); + // buffer used to hold a formatted log message prior to actually logging it. const int LOG_MSG_SIZE = 2048; char log_msg[ LOG_MSG_SIZE ]; @@ -459,12 +462,12 @@ bool pdo_sqlsrv_handle_dbh_error( sqlsrv_context& ctx, unsigned int sqlsrv_error case PDO_ERRMODE_WARNING: if( !warning ) { size_t msg_len = strlen( reinterpret_cast( error->native_message )) + SQL_SQLSTATE_BUFSIZE - + MAX_DIGITS + 1; - char* msg = static_cast( sqlsrv_malloc( msg_len )); - core_sqlsrv_format_message( msg, static_cast( msg_len ), WARNING_TEMPLATE, error->sqlstate, error->native_code, + + MAX_DIGITS + WARNING_MIN_LENGTH + 1; + sqlsrv_malloc_auto_ptr msg; + msg = static_cast( sqlsrv_malloc( msg_len ) ); + core_sqlsrv_format_message( msg, static_cast( msg_len ), WARNING_TEMPLATE, error->sqlstate, error->native_code, error->native_message ); php_error( E_WARNING, msg ); - sqlsrv_free( msg ); } ctx.set_last_error( error ); break; @@ -509,15 +512,6 @@ bool pdo_sqlsrv_handle_stmt_error( sqlsrv_context& ctx, unsigned int sqlsrv_erro ctx.set_last_error( error ); break; case PDO_ERRMODE_WARNING: - if( !warning ) { - size_t msg_len = strlen( reinterpret_cast( error->native_message )) + SQL_SQLSTATE_BUFSIZE - + MAX_DIGITS + 1; - char* msg = static_cast( sqlsrv_malloc(SQL_MAX_MESSAGE_LENGTH+1)); - core_sqlsrv_format_message( msg, static_cast( msg_len ), WARNING_TEMPLATE, error->sqlstate, error->native_code, - error->native_message ); - php_error( E_WARNING, msg ); - sqlsrv_free( msg ); - } ctx.set_last_error( error ); break; case PDO_ERRMODE_SILENT: diff --git a/pdo_sqlsrv/php_pdo_sqlsrv.h b/pdo_sqlsrv/php_pdo_sqlsrv.h index bf3285ca..97804a10 100644 --- a/pdo_sqlsrv/php_pdo_sqlsrv.h +++ b/pdo_sqlsrv/php_pdo_sqlsrv.h @@ -2,7 +2,7 @@ #define PHP_PDO_SQLSRV_H //--------------------------------------------------------------------------------------------------------------------------------- -// File: pdo_sqlsrv.h +// File: php_pdo_sqlsrv.h // // Contents: Declarations for the extension // diff --git a/pdo_sqlsrv/template.rc b/pdo_sqlsrv/template.rc index fd6ea640..fa9d72b7 100644 --- a/pdo_sqlsrv/template.rc +++ b/pdo_sqlsrv/template.rc @@ -43,8 +43,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US //Version VS_VERSION_INFO VERSIONINFO - FILEVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_MMDD, SQLVERSION_REVISION - PRODUCTVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR,SQLVERSION_MMDD,0 + FILEVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_RELEASE, SQLVERSION_BUILD + PRODUCTVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR,SQLVERSION_RELEASE,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS VS_FF_DEBUG @@ -61,13 +61,13 @@ BEGIN BEGIN VALUE "Comments", "This product includes PHP software that is freely available from http://www.php.net/software/. Copyright © 2001-2016 The PHP Group. All rights reserved.\0" VALUE "CompanyName", "Microsoft Corp.\0" - VALUE "FileDescription", "Microsoft Drivers for PHP for SQL Server (PDO Driver)\0" - VALUE "FileVersion", STRVER4(SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_MMDD, SQLVERSION_REVISION) + VALUE "FileDescription", "Microsoft Drivers for PHP for SQL Server\0" + VALUE "FileVersion", STRVER4(SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_RELEASE, SQLVERSION_BUILD) VALUE "InternalName", FILE_NAME "\0" VALUE "LegalCopyright", "Copyright Microsoft Corporation.\0" VALUE "OriginalFilename", FILE_NAME "\0" VALUE "ProductName", "Microsoft Drivers for PHP for SQL Server\0" - VALUE "ProductVersion", STRVER3(SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_MMDD) + VALUE "ProductVersion", STRVER3(SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_RELEASE) VALUE "URL", "http://www.microsoft.com\0" END END diff --git a/pdo_sqlsrv/version.h b/pdo_sqlsrv/version.h index 13c469ca..3bbc3261 100644 --- a/pdo_sqlsrv/version.h +++ b/pdo_sqlsrv/version.h @@ -16,12 +16,20 @@ // IN THE SOFTWARE. //--------------------------------------------------------------------------------------------------------------------------------- -#define VER_FILEVERSION_STR "4.1.0.0" -#define _FILEVERSION 4,1,0,0 +// helper macros to stringify the a macro value +#define STRINGIFY(a) TOSTRING(a) +#define TOSTRING(a) #a + #define SQLVERSION_MAJOR 4 #define SQLVERSION_MINOR 1 -#define SQLVERSION_MMDD 0 -#define SQLVERSION_REVISION 0 +#define SQLVERSION_RELEASE 4 +#define SQLVERSION_BUILD 0 + +#define VER_FILEVERSION_STR STRINGIFY( SQLVERSION_MAJOR ) "." STRINGIFY( SQLVERSION_MINOR ) "." STRINGIFY( SQLVERSION_RELEASE ) "." STRINGIFY( SQLVERSION_BUILD ) +#define _FILEVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR,SQLVERSION_RELEASE,SQLVERSION_BUILD +#define PHP_SQLSRV_VERSION STRINGIFY( SQLVERSION_MAJOR ) "." STRINGIFY( SQLVERSION_MINOR ) "." STRINGIFY( SQLVERSION_RELEASE ) +#define PHP_PDO_SQLSRV_VERSION PHP_SQLSRV_VERSION + diff --git a/sqlsrv/conn.cpp b/sqlsrv/conn.cpp index c2a9c70c..773f36c4 100644 --- a/sqlsrv/conn.cpp +++ b/sqlsrv/conn.cpp @@ -1205,7 +1205,7 @@ void add_conn_option_key( sqlsrv_context& ctx, zend_string* key, size_t key_len, HashTable* options_ht, zval* data TSRMLS_DC ) { int option_key = ::get_conn_option_key( ctx, key, key_len, data TSRMLS_CC ); - CHECK_CUSTOM_ERROR((option_key == SQLSRV_STMT_OPTION_INVALID ), ctx, SS_SQLSRV_ERROR_INVALID_OPTION, key ) { + CHECK_CUSTOM_ERROR((option_key == SQLSRV_STMT_OPTION_INVALID ), ctx, SS_SQLSRV_ERROR_INVALID_OPTION, ZSTR_VAL( key ) ) { throw ss::SSException(); } diff --git a/sqlsrv/core_sqlsrv.h b/sqlsrv/core_sqlsrv.h index d91a050a..1004c234 100644 --- a/sqlsrv/core_sqlsrv.h +++ b/sqlsrv/core_sqlsrv.h @@ -1612,7 +1612,7 @@ void core_sqlsrv_format_driver_error( sqlsrv_context& ctx, sqlsrv_error_const co const char* get_last_error_message( DWORD last_error = 0 ); // a wrapper around FormatMessage that can take variadic args rather than a a va_arg pointer -DWORD core_sqlsrv_format_message( char*& output_buffer, unsigned output_len, const char* format, ... ); +DWORD core_sqlsrv_format_message( char* output_buffer, unsigned output_len, const char* format, ... ); // convenience functions that overload either a reference or a pointer so we can use // either in the CHECK_* functions. diff --git a/sqlsrv/core_util.cpp b/sqlsrv/core_util.cpp index 7e12d520..fe3c4d06 100644 --- a/sqlsrv/core_util.cpp +++ b/sqlsrv/core_util.cpp @@ -306,12 +306,12 @@ void core_sqlsrv_format_driver_error( sqlsrv_context& ctx, sqlsrv_error_const co LOG( severity, "%1!s!: message = %2!s!", ctx.func(), formatted_error->native_message ); } -DWORD core_sqlsrv_format_message( char*& output_buffer, unsigned output_len, const char* format, ... ) +DWORD core_sqlsrv_format_message( char* output_buffer, unsigned output_len, const char* format, ... ) { va_list format_args; va_start( format_args, format ); - DWORD rc = FormatMessage( FORMAT_MESSAGE_FROM_STRING, format, 0, 0, static_cast(output_buffer), SQL_MAX_MESSAGE_LENGTH, &format_args ); + DWORD rc = FormatMessage( FORMAT_MESSAGE_FROM_STRING, format, 0, 0, static_cast(output_buffer), output_len, &format_args ); va_end( format_args ); diff --git a/sqlsrv/stmt.cpp b/sqlsrv/stmt.cpp index 46ee3345..d604c044 100644 --- a/sqlsrv/stmt.cpp +++ b/sqlsrv/stmt.cpp @@ -330,8 +330,8 @@ PHP_FUNCTION( sqlsrv_fetch ) ss_sqlsrv_stmt* stmt = NULL; // NOTE: zend_parse_parameter expect zend_long when the type spec is 'l',and core_sqlsrv_fetch expect short int - int fetch_style = SQL_FETCH_NEXT; // default value for parameter if one isn't supplied - zend_long fetch_offset = 0; // default value for parameter if one isn't supplied + zend_long fetch_style = SQL_FETCH_NEXT; // default value for parameter if one isn't supplied + zend_long fetch_offset = 0; // default value for parameter if one isn't supplied // take only the statement resource PROCESS_PARAMS( stmt, "r|ll", _FN_, 2, &fetch_style, &fetch_offset ); @@ -343,7 +343,7 @@ PHP_FUNCTION( sqlsrv_fetch ) throw ss::SSException(); } - bool result = core_sqlsrv_fetch( stmt, fetch_style, fetch_offset TSRMLS_CC ); + bool result = core_sqlsrv_fetch( stmt, static_cast(fetch_style), fetch_offset TSRMLS_CC ); if( !result ) { RETURN_NULL(); } @@ -383,7 +383,7 @@ PHP_FUNCTION( sqlsrv_fetch_array ) ss_sqlsrv_stmt* stmt = NULL; zend_long fetch_type = SQLSRV_FETCH_BOTH; // default value for parameter if one isn't supplied - int fetch_style = SQL_FETCH_NEXT; // default value for parameter if one isn't supplied + zend_long fetch_style = SQL_FETCH_NEXT; // default value for parameter if one isn't supplied zend_long fetch_offset = 0; // default value for parameter if one isn't supplied // retrieve the statement resource and optional fetch type (see enum SQLSRV_FETCH_TYPE), @@ -402,7 +402,7 @@ PHP_FUNCTION( sqlsrv_fetch_array ) throw ss::SSException(); } - bool result = core_sqlsrv_fetch( stmt, fetch_style, fetch_offset TSRMLS_CC ); + bool result = core_sqlsrv_fetch( stmt, static_cast(fetch_style), fetch_offset TSRMLS_CC ); if( !result ) { RETURN_NULL(); } @@ -764,8 +764,8 @@ PHP_FUNCTION( sqlsrv_fetch_object ) ss_sqlsrv_stmt* stmt = NULL; zval* class_name_z = NULL; zval* ctor_params_z = NULL; - int fetch_style = SQL_FETCH_NEXT; // default value for parameter if one isn't supplied - zend_long fetch_offset = 0; // default value for parameter if one isn't supplied + zend_long fetch_style = SQL_FETCH_NEXT; // default value for parameter if one isn't supplied + zend_long fetch_offset = 0; // default value for parameter if one isn't supplied // stdClass is the name of the system's default base class in PHP char* class_name = const_cast( STDCLASS_NAME ); @@ -801,7 +801,7 @@ PHP_FUNCTION( sqlsrv_fetch_object ) } // fetch the data - bool result = core_sqlsrv_fetch( stmt, fetch_style, fetch_offset TSRMLS_CC ); + bool result = core_sqlsrv_fetch( stmt, static_cast(fetch_style), fetch_offset TSRMLS_CC ); if( !result ) { RETURN_NULL(); } @@ -863,11 +863,11 @@ PHP_FUNCTION( sqlsrv_fetch_object ) int i = 0; zval* value_z = NULL; ZEND_HASH_FOREACH_VAL( ctor_params_ht, value_z ) { - ZVAL_COPY_VALUE( ¶ms_m[i], value_z ); - zr = ( NULL != ¶ms_m[i] ) ? SUCCESS : FAILURE; + zr = ( value_z ) ? SUCCESS : FAILURE; CHECK_ZEND_ERROR( zr, stmt, SS_SQLSRV_ERROR_ZEND_OBJECT_FAILED, class_name ) { throw ss::SSException(); } + ZVAL_COPY_VALUE(¶ms_m[i], value_z); i++; } ZEND_HASH_FOREACH_END(); } //if( !Z_ISUNDEF( ctor_params_z )) @@ -1084,8 +1084,8 @@ PHP_FUNCTION( sqlsrv_get_field ) THROW_SS_ERROR( stmt, SS_SQLSRV_ERROR_INVALID_FUNCTION_PARAMETER, _FN_ ); } - core_sqlsrv_get_field( stmt, field_index, sqlsrv_php_type, false, field_value, &field_len, false/*cache_field*/, - &sqlsrv_php_type_out TSRMLS_CC ); + core_sqlsrv_get_field( stmt, field_index, sqlsrv_php_type, false, field_value, &field_len, false/*cache_field*/, + &sqlsrv_php_type_out TSRMLS_CC ); convert_to_zval( stmt, sqlsrv_php_type_out, field_value, field_len, retval_z ); sqlsrv_free( field_value ); RETURN_ZVAL( &retval_z, 1, 1 ); diff --git a/sqlsrv/template.rc b/sqlsrv/template.rc index fd6ea640..fa9d72b7 100644 --- a/sqlsrv/template.rc +++ b/sqlsrv/template.rc @@ -43,8 +43,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US //Version VS_VERSION_INFO VERSIONINFO - FILEVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_MMDD, SQLVERSION_REVISION - PRODUCTVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR,SQLVERSION_MMDD,0 + FILEVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_RELEASE, SQLVERSION_BUILD + PRODUCTVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR,SQLVERSION_RELEASE,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS VS_FF_DEBUG @@ -61,13 +61,13 @@ BEGIN BEGIN VALUE "Comments", "This product includes PHP software that is freely available from http://www.php.net/software/. Copyright © 2001-2016 The PHP Group. All rights reserved.\0" VALUE "CompanyName", "Microsoft Corp.\0" - VALUE "FileDescription", "Microsoft Drivers for PHP for SQL Server (PDO Driver)\0" - VALUE "FileVersion", STRVER4(SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_MMDD, SQLVERSION_REVISION) + VALUE "FileDescription", "Microsoft Drivers for PHP for SQL Server\0" + VALUE "FileVersion", STRVER4(SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_RELEASE, SQLVERSION_BUILD) VALUE "InternalName", FILE_NAME "\0" VALUE "LegalCopyright", "Copyright Microsoft Corporation.\0" VALUE "OriginalFilename", FILE_NAME "\0" VALUE "ProductName", "Microsoft Drivers for PHP for SQL Server\0" - VALUE "ProductVersion", STRVER3(SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_MMDD) + VALUE "ProductVersion", STRVER3(SQLVERSION_MAJOR,SQLVERSION_MINOR, SQLVERSION_RELEASE) VALUE "URL", "http://www.microsoft.com\0" END END diff --git a/sqlsrv/version.h b/sqlsrv/version.h index 13c469ca..3bbc3261 100644 --- a/sqlsrv/version.h +++ b/sqlsrv/version.h @@ -16,12 +16,20 @@ // IN THE SOFTWARE. //--------------------------------------------------------------------------------------------------------------------------------- -#define VER_FILEVERSION_STR "4.1.0.0" -#define _FILEVERSION 4,1,0,0 +// helper macros to stringify the a macro value +#define STRINGIFY(a) TOSTRING(a) +#define TOSTRING(a) #a + #define SQLVERSION_MAJOR 4 #define SQLVERSION_MINOR 1 -#define SQLVERSION_MMDD 0 -#define SQLVERSION_REVISION 0 +#define SQLVERSION_RELEASE 4 +#define SQLVERSION_BUILD 0 + +#define VER_FILEVERSION_STR STRINGIFY( SQLVERSION_MAJOR ) "." STRINGIFY( SQLVERSION_MINOR ) "." STRINGIFY( SQLVERSION_RELEASE ) "." STRINGIFY( SQLVERSION_BUILD ) +#define _FILEVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR,SQLVERSION_RELEASE,SQLVERSION_BUILD +#define PHP_SQLSRV_VERSION STRINGIFY( SQLVERSION_MAJOR ) "." STRINGIFY( SQLVERSION_MINOR ) "." STRINGIFY( SQLVERSION_RELEASE ) +#define PHP_PDO_SQLSRV_VERSION PHP_SQLSRV_VERSION +