From bad3c5e0058aa519d9e389739997dd94a8e697ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sun, 19 Oct 2025 23:11:41 +0200 Subject: [PATCH] PHP 8.5 (compilation) support Since https://github.com/php/php-src/pull/17741, dbh->error_mode is stored as uint8_t. We cast the value to pdo_error_mode for the assignment to work. Since https://github.com/php/php-src/pull/17742, query_stmt_zval has been replaced by query_stmt_obj. The diff in the linked PR shows the new destructor usage. We follow that same usage in this commit. --- source/pdo_sqlsrv/pdo_dbh.cpp | 4 ++-- source/pdo_sqlsrv/php_pdo_sqlsrv_int.h | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/pdo_sqlsrv/pdo_dbh.cpp b/source/pdo_sqlsrv/pdo_dbh.cpp index 8f39e72fd..075134e05 100644 --- a/source/pdo_sqlsrv/pdo_dbh.cpp +++ b/source/pdo_sqlsrv/pdo_dbh.cpp @@ -625,7 +625,7 @@ int pdo_sqlsrv_db_handle_factory( _Inout_ pdo_dbh_t *dbh, _In_opt_ zval *driver_ PDO_LOG_DBH_ENTRY; hash_auto_ptr pdo_conn_options_ht; - pdo_error_mode prev_err_mode = dbh->error_mode; + pdo_error_mode prev_err_mode = static_cast( dbh->error_mode ); // must be done in all cases so that even a failed connection can query the // object for errors. @@ -1604,7 +1604,7 @@ zend_string * pdo_sqlsrv_dbh_last_id(_Inout_ pdo_dbh_t *dbh, _In_ const zend_str PDO_LOG_DBH_ENTRY; // turn off any error handling for last_id - pdo_error_mode prev_err_mode = dbh->error_mode; + pdo_error_mode prev_err_mode = static_cast( dbh->error_mode ); dbh->error_mode = PDO_ERRMODE_SILENT; sqlsrv_malloc_auto_ptr driver_stmt; diff --git a/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h b/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h index a0a6dd89b..4ce153261 100644 --- a/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h +++ b/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h @@ -301,7 +301,12 @@ inline void pdo_reset_dbh_error( _Inout_ pdo_dbh_t* dbh ) // release the last statement from the dbh so that error handling won't have a statement passed to it if( dbh->query_stmt ) { dbh->query_stmt = NULL; - zval_ptr_dtor( &dbh->query_stmt_zval ); + #if PHP_VERSION_ID < 80500 + zval_ptr_dtor( &dbh->query_stmt_zval ); + #else + OBJ_RELEASE( dbh->query_stmt_obj ); + dbh->query_stmt_obj = NULL; + #endif } // if the driver isn't valid, just return (PDO calls close sometimes more than once?)