[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
| From: | Weilin Du | Date: | Mon, 02 Nov 2026 19:43:10 +0000 |
| Subject: | [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143235@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Date: 2026-11-03T03:26:26+08:00
Commit: https://github.com/php/php-src/commit/de0e21c7128271ba64410b76bf52150eade4b4f9
Raw diff: https://github.com/php/php-src/commit/de0e21c7128271ba64410b76bf52150eade4b4f9.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
Fix GH-24990: pdo_sqlite statement unusable after failed execute() (#24991)
Changed paths:
A ext/pdo_sqlite/tests/gh24990.phpt
M NEWS
M ext/pdo_sqlite/sqlite_statement.c
Diff:
diff --git a/NEWS b/NEWS
index 9ce3817f6a46..cdfa15aceecc 100644
--- a/NEWS
+++ b/NEWS
@@ -232,6 +232,9 @@ PHP NEWS
. Fixed bug GH-25006 (getColumnMeta() reads out of bounds for an
out-of-range column index). (Ilia Alshanetsky)
+- PDO_SQLite:
+ . Fixed bug GH-24990 (Statement unusable after a failed execute()). (lazerg)
+
- Phar:
. Fixed bug GH-25093 (Phar::webPhar() redirect reads past the request URI).
(lazerg)
diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c
index 319e63aa04f3..79468ca41809 100644
--- a/ext/pdo_sqlite/sqlite_statement.c
+++ b/ext/pdo_sqlite/sqlite_statement.c
@@ -67,11 +67,10 @@ static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt)
return 1;
case SQLITE_ERROR:
- sqlite3_reset(S->stmt);
- ZEND_FALLTHROUGH;
case SQLITE_MISUSE:
case SQLITE_BUSY:
default:
+ sqlite3_reset(S->stmt);
pdo_sqlite_error_stmt(stmt);
return 0;
}
diff --git a/ext/pdo_sqlite/tests/gh24990.phpt b/ext/pdo_sqlite/tests/gh24990.phpt
new file mode 100644
index 000000000000..89bfe35e74bc
--- /dev/null
+++ b/ext/pdo_sqlite/tests/gh24990.phpt
@@ -0,0 +1,33 @@
+--TEST--
+GH-24990 (Statement unusable after a failed execute())
+--EXTENSIONS--
+pdo_sqlite
+--FILE--
+<?php
+$db = new PDO('sqlite::memory:', options: [PDO::ATTR_ERRMODE =>
PDO::ERRMODE_EXCEPTION]);
+$db->exec('CREATE TABLE test (k TEXT PRIMARY KEY NOT NULL)');
+$db->exec("INSERT INTO test VALUES ('a')");
+
+$stmt = $db->prepare('INSERT INTO test (k) VALUES (?)');
+foreach (['a', 'b', 'b', 'c'] as $k) {
+ try {
+ var_dump($stmt->execute([$k]));
+ } catch (PDOException $e) {
+ echo $e->getMessage(), "\n";
+ }
+}
+var_dump($db->query('SELECT k FROM test ORDER BY k')->fetchAll(PDO::FETCH_COLUMN));
+?>
+--EXPECT--
+SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: test.k
+bool(true)
+SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: test.k
+bool(true)
+array(3) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ [2]=>
+ string(1) "c"
+}