Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[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

Closed
wants to merge 1 commit into from

Conversation

xabbuh
Copy link
Member

@xabbuh 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())) {
Copy link
Member

Choose a reason for hiding this comment

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

Would this be enough?

Suggested change
if ($message instanceof TemplatedEmail && (!$message->getTextBody() && $message->getTextTemplate() || !$message->getHtmlBody() && $message->getHtmlTemplate())) {
if ($message instanceof TemplatedEmail && (null !== $message->getTextTemplate() || null !== $message->getHtmlTemplate())) {

Copy link
Member Author

@xabbuh xabbuh Dec 5, 2022

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

Copy link
Contributor

@ThomasTr ThomasTr Dec 5, 2022

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

Copy link
Member

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.

Copy link

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())) {

Copy link
Member

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.

@fabpot
Copy link
Member

fabpot commented Dec 6, 2022

See #48505 for an alternative fix.

@xabbuh
Copy link
Member Author

xabbuh commented Dec 6, 2022

closing in favor of #48505

@xabbuh xabbuh closed this Dec 6, 2022
fabpot added a commit that referenced this pull request Dec 6, 2022
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
@xabbuh xabbuh deleted the issue-48472 branch December 19, 2022 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.