From 86a2e4d017155f00f4d23e4fde880ef9740399b6 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Sat, 13 Dec 2025 14:26:27 +0100 Subject: [PATCH 1/3] Fix GH-20699: SQLite3Result fetchArray return array|false, null returned --- ext/sqlite3/sqlite3.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 9b3286b70220d..b16be6932a07b 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -2011,6 +2011,7 @@ PHP_METHOD(SQLite3Result, fetchArray) default: php_sqlite3_error(result_obj->db_obj, sqlite3_errcode(sqlite3_db_handle(result_obj->stmt_obj->stmt)), "Unable to execute statement: %s", sqlite3_errmsg(sqlite3_db_handle(result_obj->stmt_obj->stmt))); + RETURN_FALSE; } } /* }}} */ From a7f5bed46c6e3e1fac7fadf0a15ba892be46d660 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Sun, 14 Dec 2025 19:35:43 +0100 Subject: [PATCH 2/3] test --- ext/sqlite3/tests/gh20699.phpt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 ext/sqlite3/tests/gh20699.phpt diff --git a/ext/sqlite3/tests/gh20699.phpt b/ext/sqlite3/tests/gh20699.phpt new file mode 100644 index 0000000000000..d2042b7eab256 --- /dev/null +++ b/ext/sqlite3/tests/gh20699.phpt @@ -0,0 +1,13 @@ +--TEST-- +GH-20699 (SQLite3Result fetchArray return array|false, null returned) +--EXTENSIONS-- +sqlite3 +--CREDITS-- +plusminmax +--FILE-- +prepare('BEGIN;')->execute()->fetchArray(); +?> +--EXPECTF-- +Warning: SQLite3Result::fetchArray(): Unable to execute statement: cannot start a transaction within a transaction in %s on line %d From d022446d5f81697cf93a9a0435b2380320df3771 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Sun, 14 Dec 2025 22:30:32 +0100 Subject: [PATCH 3/3] Dump result --- ext/sqlite3/tests/gh20699.phpt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/sqlite3/tests/gh20699.phpt b/ext/sqlite3/tests/gh20699.phpt index d2042b7eab256..1b53bfc98e39f 100644 --- a/ext/sqlite3/tests/gh20699.phpt +++ b/ext/sqlite3/tests/gh20699.phpt @@ -7,7 +7,8 @@ plusminmax --FILE-- prepare('BEGIN;')->execute()->fetchArray(); +var_dump($db->prepare('BEGIN;')->execute()->fetchArray()); ?> --EXPECTF-- Warning: SQLite3Result::fetchArray(): Unable to execute statement: cannot start a transaction within a transaction in %s on line %d +bool(false)