-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] bug - fix EsmtpTransport variable $code definition #51568
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
the variable $code defined in the foreach loop, if there is no authenticators, then the $code will not be defined and therefore the following TransportException gives a PHP error. the use-case defined as a unit test in EsmtpTransportTest class.
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
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.
For 5.4?
I checked it for 5.4. This bug does not exist on 5.4. |
Thank you @kgnblg. |
@@ -192,7 +193,6 @@ private function handleAuth(array $modes): void | |||
continue; | |||
} | |||
|
|||
$code = null; |
There was a problem hiding this co 8000 mment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we still reset it on each iteration of the loop ?
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.
yes, you are right. I added it in my forked branch should I create a new PR?
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.
Please do :)
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.
Here it is: #51581 :)
…revent wrong exception codes (kgnblg) This PR was merged into the 6.3 branch. Discussion ---------- [Mailer] bug - reset $code variable each iteration for prevent wrong exception codes | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | --- | License | MIT | Doc PR | --- Follow up PR of #51568 to reset `$code` variable for each iteration to have correct `TransportException` code. (Note: This bug does not exist in version 5.4) Commits ------- ce4bc8c [mailer] reset $code variable each iteration for prevent wrong codes to be used
This PR contains a basic fix of a bug in SymfonyMailer component (
Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport
class).If we use
EsmtpTransport
like the given example, it needs to throw TransportException which has been defined in thehandleAuth()
ofEsmtpTransport
class. (Because we calledsetAuthenticators()
with empty array and the function emptied the authenticators. We can imagine that we forget to set authenticators.)This code piece needs to throw following TransportException with code 504;
However it shows a PHP Error;
I included a unit test function
testConstructorWithEmptyAuthenticator()
inside of theEsmtpTransportTest
class with a fix of the problem.