Skip to content

Fix GH-23962: Don't roll back a persistent PDO handle still in use - #23963

Merged
kamil-tekiela merged 2 commits into
php:PHP-8.4from
lazerg:fix/gh-23962-persistent-rollback
Sep 28, 2026
Merged

kamil-tekiela merged 2 commits into
php:PHP-8.4from
lazerg:fix/gh-23962-persistent-rollback

Conversation

@lazerg

@lazerg lazerg commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

pdo_dbh_free_storage() rolled back an open transaction whenever a PDO object was freed, before dbh_free() had a chance to see that the persistent handle was still shared. So unsetting one of two persistent instances with the same DSN rolled back the transaction the other one had just started.

The rollback now only runs for a persistent handle when no other object holds it, i.e. refcount is at most 2 (the persistent list keeps one reference). Freeing the last object still rolls back, so an open transaction doesn't leak into the next request.

Fixes GH-23962

@kamil-tekiela kamil-tekiela left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me.

@kamil-tekiela
kamil-tekiela merged commit 3109800 into php:PHP-8.4 Sep 28, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants