8000 MasterSlaveConnection::query() throws driver-specific exceptions (e.g. PDOException etc) by supersmile2009 · Pull Request #4248 · doctrine/dbal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

MasterSlaveConnection:: 8000 query() throws driver-specific exceptions (e.g. PDOException etc) #4248

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

Conversation

supersmile2009
Copy link
Q A
Type bug
BC Break no, but it depends*
Fixed issues #2769, #3118

Summary

This PR fixes how driver exceptions are handled in Doctrine/DBAL/Connections/MasterSlaveConnection::query() and prevents driver-specific exceptions from bubbling. Driver exception conversion was added in 4cc70c1, but somehow MasterSlaveConnection was forgotten.
This PR reduces code duplication by calling the parent method, so no more chance of forgetting to apply some change to MasterSlaveConnection if Doctrine\DBAL\Connection::query() is modified. At the end of the day except for the proper exception handling parent's method behavior is the same.

Alternative PRs

Unlike #3313, this PR addresses only the core issue - exception not being converted. That PR suggests catching PDOException in addition to DBALException, which is completely unnecessary if exception is properly converted. Also unlike #3313, this PR adds a localized unit test, while the other PR tests merely a side-effect on the ping method.

BC Break

Any bug fix is a change of behavior, which can be a potential BC break for someone. Any of the 3rd party code that relies on current buggy behavior which in fact violates the contract would get broken by this change.
So in practice it's a BC break for some projects that probably tried to implement some workarounds for this bug. But ignoring exploitation of undocumented/buggy behavior when making stuff work according to the spec is a common thing when evaluating if a change breaks BC. The only exception that is supposed to be thrown out of the query method is DBALException as advertised in the docblock. Therefore I wouldn't consider it a BC break.

Other

I can see 2.11.x branch has some significant changes around the code affected by this PR. I could create a separate PR for 2.11 if you consider this solution good enough.

@supersmile2009 supersmile2009 changed the base branch from 2.11.x to 2.10.x September 2, 2020 21:25
@supersmile2009 supersmile2009 force-pushed the bugfix/exception-handling-master-slave branch from 0d9b977 to bf5e969 Compare September 3, 2020 08:56
@supersmile2009 supersmile2009 force-pushed the bugfix/exception-handling-master-slave branch from bf5e969 to 84d9ffd Compare September 3, 2020 08:58
@supersmile2009 supersmile2009 force-pushed the bugfix/exception-handling-master-slave branch 2 times, most recently from df7b408 to fe7ef75 Compare September 3, 2020 10:08
@supersmile2009 supersmile2009 changed the title Bugfix/exception handling master slave MasterSlaveConnection::query() throws driver-specific exceptions (e.g. PDOException etc) Sep 3, 2020
@morozov morozov requested a review from beberlei September 12, 2020 19:02
@morozov
Copy link
Member
morozov commented Oct 4, 2020

@beberlei, as the one who insisted on keeping this functionality in the library, please provide your review.

@beberlei
Copy link
Member
beberlei commented Dec 7, 2020

Superseded by #4456

@beberlei beberlei closed this Dec 7, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0