[php-src] master: Merge branch 'PHP-8.6'
| From: | Kamil Tekiela | Date: | Mon, 28 Sep 2026 21:55:51 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141651@lists.php.net to get a copy of this message | ||
Author: Kamil Tekiela (kamil-tekiela)
Date: 2026-09-28T22:55:21+01:00
Commit: https://github.com/php/php-src/commit/a36204b1d916689a66e5f0337fb6e5055c228dc0
Raw diff: https://github.com/php/php-src/commit/a36204b1d916689a66e5f0337fb6e5055c228dc0.diff
Merge branch 'PHP-8.6'
Changed paths:
A ext/pdo_sqlite/tests/gh23962.phpt
M NEWS
M ext/pdo/pdo_dbh.c
Diff:
diff --git a/NEWS b/NEWS
index 55f91f94b168..b38484a71ac1 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,8 @@ PHP NEWS
column index. (Ilia Alshanetsky)
. Fixed PDOStatement::bindColumn() registering a binding for a column name
that is not in the result set. (Ilia Alshanetsky)
+ . Fixed bug GH-23962 (Destroying a persistent PDO instance rolls back a
+ transaction still in use by another instance). (Lazizbek Ergashev)
- PGSQL:
. Fixed pg_lo_write() rejecting data containing null bytes. (Ilia Alshanetsky)
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index 5aa95cdccaf0..56320c3eb323 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -1592,7 +1592,9 @@ static void pdo_dbh_free_storage(zend_object *std)
return;
}
- if (dbh->driver_data && dbh->methods && dbh->methods->rollback
&& pdo_is_in_transaction(dbh)) {
+ /* The persistent list holds one reference, other objects may hold the rest */
+ if (dbh->driver_data && dbh->methods && dbh->methods->rollback
+ && (!dbh->is_persistent || dbh->refcount <= 2) &&
pdo_is_in_transaction(dbh)) {
dbh->methods->rollback(dbh);
dbh->in_txn = false;
}
diff --git a/ext/pdo_sqlite/tests/gh23962.phpt b/ext/pdo_sqlite/tests/gh23962.phpt
new file mode 100644
index 000000000000..d4c1cc4e4e0f
--- /dev/null
+++ b/ext/pdo_sqlite/tests/gh23962.phpt
@@ -0,0 +1,31 @@
+--TEST--
+GH-23962 (Destroying a persistent PDO instance rolls back a transaction still in use by another
instance)
+--CREDITS--
+BoyeMagnus
+--EXTENSIONS--
+pdo_sqlite
+--FILE--
+<?php
+$dsn = 'sqlite::memory:';
+
+$a = new PDO($dsn, null, null, [PDO::ATTR_PERSISTENT => true]);
+$b = new PDO($dsn, null, null, [PDO::ATTR_PERSISTENT => true]);
+
+$b->beginTransaction();
+unset($a);
+var_dump($b->inTransaction());
+var_dump($b->commit());
+
+$b->beginTransaction();
+$b->exec('CREATE TABLE test (a int)');
+unset($b);
+
+$c = new PDO($dsn, null, null, [PDO::ATTR_PERSISTENT => true]);
+var_dump($c->inTransaction());
+var_dump($c->query("SELECT count(*) FROM sqlite_master WHERE name =
'test'")->fetchColumn());
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+int(0)