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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.

throw new LogicException(sprintf('You must configure a "%s" when a "%s" instance has a text or HTML template set.', BodyRendererInterface::class, get_debug_type($message)));
}

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