Commit be4e9ee7198 for php
commit be4e9ee71982a821c43810fdcff6e83849299b18
Merge: 1efdcc6b654 11690db1787
Author: Ilia Alshanetsky <ilia@ilia.ws>
Date: Wed Sep 30 08:16:42 2026 -0400
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
ext/pdo: Drop the previous result when execute() fails
diff --cc ext/pdo_sqlite/tests/pdo_sqlite_failed_execute.phpt
index 00000000000,c483c6dd959..b711855e2af
mode 000000,100644..100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_failed_execute.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_failed_execute.phpt
@@@ -1,0 -1,83 +1,85 @@@
+ --TEST--
+ PDO SQLite: failed execute invalidates the previous result
+ --EXTENSIONS--
+ pdo_sqlite
+ --FILE--
+ <?php
+
+ $db = new PDO('sqlite::memory:');
+
+ $stmt = $db->prepare('SELECT ? AS value UNION ALL SELECT 2');
+ $stmt->execute(['first']);
+ var_dump($stmt->fetchColumn());
+
+ try {
+ $stmt->execute([new stdClass()]);
+ } catch (Error $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+ }
+ var_dump($stmt->fetchColumn());
+
+ $stmt->execute(['third']);
+ var_dump($stmt->fetchAll(PDO::FETCH_COLUMN));
+
+ $db->sqliteCreateFunction('fail_execute', function (bool $fail): string {
+ if ($fail) {
+ throw new RuntimeException('execution failed');
+ }
+ return 'first';
+ });
+ $stmt = $db->prepare('SELECT fail_execute(?) AS value UNION ALL SELECT 2');
+ $stmt->execute([false]);
+ var_dump($stmt->fetchColumn());
+
+ try {
+ $stmt->execute([true]);
+ } catch (RuntimeException $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+ }
+ var_dump($stmt->fetchColumn());
+
+ $stmt->execute([false]);
+ var_dump($stmt->fetchAll(PDO::FETCH_COLUMN));
+
+ $db->exec('CREATE TABLE failed_execute (value INTEGER UNIQUE)');
+ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+ $stmt = $db->prepare('INSERT INTO failed_execute VALUES (?)');
+ $stmt->execute([1]);
+ $warnings = 0;
+ set_error_handler(function () use (&$warnings): bool {
+ $warnings++;
+ return true;
+ });
+ try {
+ var_dump($stmt->execute([1]));
+ } finally {
+ restore_error_handler();
+ }
+ echo "driver warnings: $warnings\n";
+ var_dump($stmt->fetchColumn());
+
+ ?>
---EXPECT--
++--EXPECTF--
+ string(5) "first"
+ Error: Object of class stdClass could not be converted to string
+ bool(false)
+ array(2) {
+ [0]=>
+ string(5) "third"
+ [1]=>
+ int(2)
+ }
++
++Deprecated: Method PDO::sqliteCreateFunction() is deprecated since 8.5, use Pdo\Sqlite::createFunction() instead in %s on line %d
+ string(5) "first"
+ RuntimeException: execution failed
+ bool(false)
+ array(2) {
+ [0]=>
+ string(5) "first"
+ [1]=>
+ int(2)
+ }
+ bool(false)
+ driver warnings: 1
+ bool(false)