8000 [Notifier] Fix notifier profiler when transport name is null by fabpot · Pull Request #49326 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Notifier] Fix notifier profiler when transport name is null #49326

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 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
10000
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 @@ -17,7 +17,7 @@

{% for transport in events.transports %}
<div class="sf-toolbar-info-piece">
<b>{{ transport }}</b>
<b>{{ transport ?: '<em>Empty Transport Name</em>' }}</b>
<span class="sf-toolbar-status">{{ events.messages(transport)|length }}</span>
</div>
{% endfor %}
Expand Down Expand Up @@ -100,7 +100,7 @@
</div>

{% for transport in events.transports %}
<h3>{{ transport }}</h3>
<h3>{{ transport ?: '<em>Empty Transport Name</em>' }}</h3>

<div class="card-block">
<div class="sf-tabs sf-tabs-sm">
Expand Down
10000
4 changes: 2 additions & 2 deletions src/Symfony/Component/Notifier/Event/NotificationEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class NotificationEvents
public function add(MessageEvent $event): void
{
$this->events[] = $event;
$this->transports[$event->getMessage()->getTransport()] = true;
$this->transports[(string) $event->getMessage()->getTransport()] = true;
Copy link
Member Author

Choose a reason for hiding this comment

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

null is anyway converted to an empty string by PHP. Let's be explicit here.

}

public function getTransports(): array
Expand All @@ -43,7 +43,7 @@ public function getEvents(string $name = null): array

$events = [];
foreach ($this->events as $event) {
if ($name === $event->getMessage()->getTransport()) {
if ($name === (string) $event->getMessage()->getTransport()) {
Copy link
Member

Choose a reason for hiding this comment

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

not sure about this one: do we support the empty string as transport name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

$events[] = $event;
}
}
Expand Down
0