Skip to content

[Mailer] Simplify fix #53950

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

Merged
merged 1 commit into from
Feb 15, 2024
Merged

Conversation

HypeMC
Copy link
Member

@HypeMC HypeMC commented Feb 14, 2024

Q A
Branch? 5.4
Bug fix? no
New feature? no
Deprecations? no
Issues -
License MIT

Follow-up to #53934, I didn't notice the getBodyAsString() method, it simplifies the code nicely.

For 6.4+: HypeMC@1bb254d

diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig
index a0d2d6388b..e220e73d4b 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/mailer.html.twig
@@ -282,7 +282,7 @@
                                         {% if event.message.subject is defined %}
                                             {{ event.message.getSubject() ?? '(No subject)' }}
                                         {% elseif event.message.headers.has('subject') %}
-                                            {{ event.message.headers.get('subject').toString()|split(': ', 2)[1]|default('(No subject)') }}
+                                            {{ event.message.headers.get('subject').bodyAsString()|default('(No subject)') }}
                                         {% else %}
                                             (No subject)
                                         {% endif %}
@@ -291,7 +291,7 @@
                                         {% if event.message.to is defined %}
                                             {{ event.message.getTo()|map(addr => addr.toString())|join(', ')|default('(empty)') }}
                                         {% elseif event.message.headers.has('to') %}
-                                            {{ event.message.headers.get('to').toString()|split(': ', 2)[1]|default('(empty)') }}
+                                            {{ event.message.headers.get('to').bodyAsString()|default('(empty)') }}
                                         {% else %}
                                             (empty)
                                         {% endif %}
@@ -342,7 +342,7 @@
                                 {% if message.subject is defined %}
                                     {{ message.getSubject() ?? '(No subject)' }}
                                 {% elseif message.headers.has('subject') %}
-                                    {{ message.headers.get('subject').toString()|split(': ', 2)[1]|default('(No subject)') }}
+                                    {{ message.headers.get('subject').bodyAsString()|default('(No subject)') }}
                                 {% else %}
                                     (No subject)
                                 {% endif %}
@@ -353,7 +353,7 @@
                                     {% if message.from is defined %}
                                         {{ message.getFrom()|map(addr => addr.toString())|join(', ')|default('(empty)') }}
                                     {% elseif message.headers.has('from') %}
-                                        {{ message.headers.get('from').toString()|split(': ', 2)[1]|default('(empty)') }}
+                                        {{ message.headers.get('from').bodyAsString()|default('(empty)') }}
                                     {% else %}
                                         (empty)
                                     {% endif %}
@@ -363,7 +363,7 @@
                                     {% if message.to is defined %}
                                         {{ message.getTo()|map(addr => addr.toString())|join(', ')|default('(empty)') }}
                                     {% elseif message.headers.has('to') %}
-                                        {{ message.headers.get('to').toString()|split(': ', 2)[1]|default('(empty)') }}
+                                        {{ message.headers.get('to').bodyAsString()|default('(empty)') }}
                                     {% else %}
                                         (empty)
                                     {% endif %}

@nicolas-grekas
Copy link
Member

Thank you @HypeMC.

@nicolas-grekas nicolas-grekas merged commit 8802b0e into symfony:5.4 Feb 15, 2024
@HypeMC HypeMC deleted the fix-mailer-profiler-2 branch February 15, 2024 11:21
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