-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] require a body renderer only if message has not been rendered yet #48481
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
xabbuh
commented
Dec 5, 2022
Q | A |
---|---|
Branch? | 6.2 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Tickets | Fix #48472 |
License | MIT |
Doc PR |
@@ -76,7 +76,7 @@ public function send(RawMessage $message, Envelope $envelope = null): ?SentMessa | ||
$envelope = $event->getEnvelope(); | ||
$message = $event->getMessage(); | ||
|
||
if ($message instanceof TemplatedEmail && ($message->getTextTemplate() || $message->getHtmlTemplate())) { | ||
if ($message instanceof TemplatedEmail && (!$message->getTextBody() && $message->getTextTemplate() || !$message->getHtmlBody() && $message->getHtmlTemplate())) { |
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.
Would this be enough?
if ($message instanceof TemplatedEmail && (!$message->getTextBody() && $message->getTextTemplate() || !$message->getHtmlBody() && $message->getHtmlTemplate())) { | |
if ($message instanceof TemplatedEmail && (null !== $message->getTextTemplate() || null !== $message->getHtmlTemplate())) { |
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.
I don't think so. Both methods are overwritten in the NotificationEmail
class: https://github.com/symfony/symfony/blob/6.2/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php#L158-L174
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 me
(null !== $message->getTextTemplate() || null !== $message->getHtmlTemplate())
is true
, $message->getTextTemplate()
is @email/default/notification/body.txt.twig
and $message->getHtmlTemplate()
is @email/default/notification/body.html.twig
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.
Let me have a look.
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 my issue #48472 this fixes it:
if ($message instanceof TemplatedEmail && (!$message->getTextBody() && $message->getTextTemplate() || !$message->getHtmlBody() && $message->getHtmlTemplate())) {
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.
See #48505 for an alternative fix.
See #48505 for an alternative fix. |
closing in favor of #48505 |
This PR was merged into the 6.2 branch. Discussion ---------- [Mailer] Fix rendered templates for notifications | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #48472 | License | MIT | Doc PR | n/a Alternative to #48481 Commits ------- 085185d [Mailer] Fix rendered templates for notifications