From acd0898bdfb12fb34f422b3fffe54d747f89c235 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] Fix GH-20699: SQLite3Result fetchArray return array|false, null returned Closes GH-20701. --- NEWS | 4 ++++ ext/sqlite3/sqlite3.c | 1 + ext/sqlite3/tests/gh20699.phpt | 14 ++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 ext/sqlite3/tests/gh20699.phpt diff --git a/NEWS b/NEWS index 13f673a53c0..4e301bdbc8b 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,10 @@ PHP NEWS . Fixed bug GH-20678 (resource created by GlobIterator crashes with fclose()). (David Carlier) +- Sqlite3: + . Fixed bug GH-20699 (SQLite3Result fetchArray return array|false, + null returned). (ndossche, plusminmax) + - Standard: . Fix error check for proc_open() command. (ndossche) diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 9b3286b7022..b16be6932a0 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; } } /* }}} */ diff --git a/ext/sqlite3/tests/gh20699.phpt b/ext/sqlite3/tests/gh20699.phpt new file mode 100644 index 00000000000..1b53bfc98e3 --- /dev/null +++ b/ext/sqlite3/tests/gh20699.phpt @@ -0,0 +1,14 @@ +--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 +bool(false)