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

Run risky code in finally block #11646

Open
wants to merge 1 commit into
base: 2.19.x
Choose a base branch
from

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Oct 9, 2024

catch blocks are not supposed to fail. If you want to do something despite an exception happening, you should do it in a finally block.

(finally) Fixes #7545

catch blocks are not supposed to fail. If you want to do something
despite an exception happening, you should do it in a finally block.

Closes doctrine#7545
@greg0ire
Copy link
Member Author

greg0ire commented Oct 9, 2024

Should I move the call to commit() inside the finally block as well? 🤔

Copy link
Member

@SenseException SenseException left a comment

Choose a reason for hiding this comment

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

Should I move the call to commit() inside the finally block as well? 🤔

I don't know. It looks like it would all be the same in your changes. Logically, from a reading perspective, it would look weird if the commit would be in finally

Does anyone know why $conn->isTransactionActive() wasn't used in the EntityManager in the past?

@ro0NL
Copy link

ro0NL commented Oct 9, 2024

as a transaction was started, it should be active during rollback

if not, it exposes userland closed more transactions than it opened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants