[php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Mon, 28 Sep 2026 21:55:05 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141649@lists.php.net to get a copy of this message
Author: Kamil Tekiela (kamil-tekiela) Date: 2026-09-28T22:54:08+01:00 Commit: https://github.com/php/php-src/commit/228dd15a777cd3619498a97459f30cc8387275f6 Raw diff: https://github.com/php/php-src/commit/228dd15a777cd3619498a97459f30cc8387275f6.diff Merge branch 'PHP-8.4' into PHP-8.5 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 23a8d2d3c8a1..7b95a9508301 100644 --- a/NEWS +++ b/NEWS @@ -91,6 +91,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 43c2cf8c0945..52486f337dd2 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -1588,7 +1588,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)

« previous php.cvs (#141649) next »