-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Messenger] Fix unreachable catch #62250
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
[Messenger] Fix unreachable catch #62250
Conversation
|
Isn't this affecting older branches as well ? Bug fixes must be submitted to the lowest affected branch. |
c40d9b5 to
fa3e311
Compare
Thanks for calling it out. Switched base branch to |
|
I don't understand why moving the |
|
The more specific exception has to come first: |
<?php
class DriverException extends Exception {}
class TableNotFoundException extends DriverException {}
try {
throw new TableNotFoundException();
} catch (DriverException $_e) {
var_dump('driver #1');
} catch (TableNotFoundException $_e) {
var_dump('table not found #1');
}
try {
throw new TableNotFoundException();
} catch (TableNotFoundException $_e) {
var_dump('table not found #2');
} catch (DriverException $_e) {
var_dump('driver #2');
}Outputs |
|
@xabbuh multiple |
|
Can you please add a test that prevents us from reintroducing this in the future? |
I know. I got confused by us having an alias for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These test cases should be added to the existing Doctrine bridge ConnectionTest class.
src/Symfony/Component/Messenger/Tests/Transport/ConnectionTest.php
Outdated
Show resolved
Hide resolved
| $exception = $this->createMock($exceptionClass); | ||
| $dbalConnection->method('delete')->willThrowException($exception); | ||
|
|
||
| $dbalConnection->method('beginTransaction')->willThrowException(new Exception('Transaction started')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwing this to prevent further execution of
symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php
Line 179 in fa3e311
| $this->driverConnection->beginTransaction(); |
src/Symfony/Component/Messenger/Tests/Transport/ConnectionTest.php
Outdated
Show resolved
Hide resolved
|
@xabbuh @stof can someone please re-run |
| } catch (TableNotFoundException $e) { | ||
| if ($this->autoSetup) { | ||
| $this->setup(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on closer inspection, this could just removed: the autosetup will happen below anyway
| } catch (TableNotFoundException $e) { | |
| if ($this->autoSetup) { | |
| $this->setup(); | |
| } |
this also means no test case can cover the change - there's nothing to test here
b43ce2a to
affca58
Compare
|
Thank you @SerheyDolgushev. |
Fix for
PhanUnreachableCatchphan issues: