From 824d1f95ad1cdf28d0159d2b9231875a5f5666c7 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 6 Jul 2023 22:02:56 +0200 Subject: [PATCH] Fix replaced error handling in SQLite3Stmt::__construct The error handling is replaced using zend_replace_error_handling(), but when SQLITE3_CHECK_INITIALIZED() returns early, the old error handling isn't restored. In the past, SQLITE3_CHECK_INITIALIZED() threw a warning when the check failed. This was replaced a few years ago with an error exception. So we can fix the bug by just removing the replacing error handling as it accomplishes nothing anymore. Closes GH-11607. --- NEWS | 3 +++ ext/sqlite3/sqlite3.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 62eaced222675..cd60985e00a97 100644 --- a/NEWS +++ b/NEWS @@ -46,6 +46,9 @@ PHP NEWS - Standard: . Fix serialization of RC1 objects appearing in object graph twice. (ilutov) +- SQLite3: + . Fix replaced error handling in SQLite3Stmt::__construct. (nielsdos) + 06 Jul 2023, PHP 8.1.21 - CLI: diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index d1a85e96009d6..de6d55a3879fb 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -1820,7 +1820,6 @@ PHP_METHOD(SQLite3Stmt, __construct) zval *db_zval; zend_string *sql; int errcode; - zend_error_handling error_handling; php_sqlite3_free_list *free_item; stmt_obj = Z_SQLITE3_STMT_P(object); @@ -1831,9 +1830,7 @@ PHP_METHOD(SQLite3Stmt, __construct) db_obj = Z_SQLITE3_DB_P(db_zval); - zend_replace_error_handling(EH_THROW, NULL, &error_handling); SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3) - zend_restore_error_handling(&error_handling); if (!ZSTR_LEN(sql)) { RETURN_FALSE;