File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ PHP NEWS
9292 column index. (Ilia Alshanetsky)
9393 . Fixed PDOStatement::bindColumn() registering a binding for a column name
9494 that is not in the result set. (Ilia Alshanetsky)
95+ . Fixed bug GH-23962 (Destroying a persistent PDO instance rolls back a
96+ transaction still in use by another instance). (Lazizbek Ergashev)
9597
9698- Readline:
9799 . Fixed a heap over-read in the interactive shell prompt when cli.prompt is
Original file line number Diff line number Diff line change @@ -1521,7 +1521,9 @@ static void pdo_dbh_free_storage(zend_object *std)
15211521 return ;
15221522 }
15231523
1524- if (dbh -> driver_data && dbh -> methods && dbh -> methods -> rollback && pdo_is_in_transaction (dbh )) {
1524+ /* The persistent list holds one reference, other objects may hold the rest */
1525+ if (dbh -> driver_data && dbh -> methods && dbh -> methods -> rollback
1526+ && (!dbh -> is_persistent || dbh -> refcount <= 2 ) && pdo_is_in_transaction (dbh )) {
15251527 dbh -> methods -> rollback (dbh );
15261528 dbh -> in_txn = false;
15271529 }
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-23962 (Destroying a persistent PDO instance rolls back a transaction still in use by another instance)
3+ --CREDITS--
4+ BoyeMagnus
5+ --EXTENSIONS--
6+ pdo_sqlite
7+ --FILE--
8+ <?php
9+ $ dsn = 'sqlite::memory: ' ;
10+
11+ $ a = new PDO ($ dsn , null , null , [PDO ::ATTR_PERSISTENT => true ]);
12+ $ b = new PDO ($ dsn , null , null , [PDO ::ATTR_PERSISTENT => true ]);
13+
14+ $ b ->beginTransaction ();
15+ unset($ a );
16+ var_dump ($ b ->inTransaction ());
17+ var_dump ($ b ->commit ());
18+
19+ $ b ->beginTransaction ();
20+ $ b ->exec ('CREATE TABLE test (a int) ' );
21+ unset($ b );
22+
23+ $ c = new PDO ($ dsn , null , null , [PDO ::ATTR_PERSISTENT => true ]);
24+ var_dump ($ c ->inTransaction ());
25+ var_dump ($ c ->query ("SELECT count(*) FROM sqlite_master WHERE name = 'test' " )->fetchColumn ());
26+ ?>
27+ --EXPECT--
28+ bool(true)
29+ bool(true)
30+ bool(false)
31+ int(0)
You can’t perform that action at this time.
0 commit comments