Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PDO transaction methods throw PDOException&DriverException #5890

Merged
merged 1 commit into from
Feb 2, 2023
Merged

Make PDO transaction methods throw PDOException&DriverException #5890

merged 1 commit into from
Feb 2, 2023

Conversation

maxm86545
Copy link
Contributor

Fixes to match \Doctrine\DBAL\Driver\Connection: beginTransaction, commit and rollBack must throw \Doctrine\DBAL\Driver\Exception. For backwards compatibility \PDOException has been keep for version 3.*. Replace #5886

Previous behavior:

try {
   $connection->beginTransaction();
} catch(\PDOException) {
  // The code can be executed
}
try {
   $connection->beginTransaction();
} catch(\Doctrine\DBAL\Driver\Exception) {
  // The code will never be executed :(
}

Current behavior:

try {
   $connection->beginTransaction();
} catch(\PDOException) {
  // The code can be executed
}
try {
   $connection->beginTransaction();
} catch(\Doctrine\DBAL\Driver\Exception) {
  // The code can be executed :)
}

@derrabus

This comment was marked as outdated.

@derrabus
Copy link
Member

derrabus commented Feb 1, 2023

Oh, now I get what you're doing here. Yeah, that might work. Will have a closer look later. Thanks for the PR.

src/Driver/PDO/Connection.php Outdated Show resolved Hide resolved
src/Driver/PDO/Connection.php Outdated Show resolved Hide resolved
src/Driver/PDO/DriverAndPDOException.php Outdated Show resolved Hide resolved
src/Driver/PDO/DriverAndPDOException.php Outdated Show resolved Hide resolved
src/Driver/PDO/DriverAndPDOException.php Outdated Show resolved Hide resolved
@derrabus derrabus added this to the 3.5.4 milestone Feb 2, 2023
@derrabus derrabus changed the title PDOException&DriverException Make PDO transaction methods throw PDOException&DriverException Feb 2, 2023
@derrabus derrabus merged commit 2828cbf into doctrine:3.5.x Feb 2, 2023
@maxm86545 maxm86545 deleted the pdoexception branch February 3, 2023 08:47
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants