From a0d743ca174fe5e0b64ecae27682acf03bd96eae Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Thu, 9 Apr 2026 03:34:04 +0100 Subject: [PATCH 1/2] ext/pdo_dblib: Added dblib_handle_check_liveness handler (#21681) Closes #21681 In case of persistent connection it was not checked if the connection was still alive always assuming it was. If the connection was broken this caused PHP to reuse the broken connection over and over. dbdead function is supported by all dblib implementation (MS, Sybase, FreeTDS). Change tested manually, see https://github.com/FreeTDS/freetds/issues/711#issuecomment-4211772091 Signed-off-by: Frediano Ziglio --- NEWS | 3 +++ UPGRADING | 4 ++++ ext/pdo_dblib/dblib_driver.c | 13 ++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index fd17715973a8..45524b382c73 100644 --- a/NEWS +++ b/NEWS @@ -99,6 +99,9 @@ PHP NEWS . Added TLS session resumption support for streams with new context options and Openssl\Session class. (Jakub Zelenka) +- PDO_DBLIB; + . Added dblib_handle_check_liveness handler. (freddy77) + - PDO_PGSQL: . Clear session-local state disconnect-equivalent processing. (KentarouTakeda) diff --git a/UPGRADING b/UPGRADING index 088f5b620bd4..fa10bd149f08 100644 --- a/UPGRADING +++ b/UPGRADING @@ -204,6 +204,10 @@ PHP 8.6 UPGRADE NOTES . Output of openssl_x509_parse() contains criticalExtensions listing all critical certificate extensions. +- PDO_DBLIB: + . When using persistent connections, there is now a liveness check in the + constructor. + - Phar: . Phar::mungServer() now supports reference values. diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index 42ba72b40ede..9f590c9071b6 100644 --- a/ext/pdo_dblib/dblib_driver.c +++ b/ext/pdo_dblib/dblib_driver.c @@ -420,6 +420,17 @@ static int dblib_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_valu return 1; } +static zend_result dblib_handle_check_liveness(pdo_dbh_t *dbh) +{ + pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; + + if (dbdead(H->link)) { + return FAILURE; + } + + return SUCCESS; +} + static const struct pdo_dbh_methods dblib_methods = { dblib_handle_closer, dblib_handle_preparer, @@ -432,7 +443,7 @@ static const struct pdo_dbh_methods dblib_methods = { dblib_handle_last_id, /* last insert id */ dblib_fetch_error, /* fetch error */ dblib_get_attribute, /* get attr */ - NULL, /* check liveness */ + dblib_handle_check_liveness, /* check_liveness */ NULL, /* get driver methods */ NULL, /* request shutdown */ NULL, /* in transaction, use PDO's internal tracking mechanism */ From 334287d18fe0a74a1280aa13a1f20fa79d6e34c1 Mon Sep 17 00:00:00 2001 From: Saki Takamachi Date: Sun, 3 May 2026 16:27:41 +0900 Subject: [PATCH 2/2] Fix indentation in UPGRADING related #21681 --- UPGRADING | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADING b/UPGRADING index fa10bd149f08..4cbe4a981052 100644 --- a/UPGRADING +++ b/UPGRADING @@ -206,7 +206,7 @@ PHP 8.6 UPGRADE NOTES - PDO_DBLIB: . When using persistent connections, there is now a liveness check in the - constructor. + constructor. - Phar: . Phar::mungServer() now supports reference values.