Skip to content

Commit 96e30a5

Browse files
committed
[bundle][profiler] Fix array to string conversion notice.
1 parent c6d5197 commit 96e30a5

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

pkg/enqueue-bundle/Profiler/MessageQueueCollector.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Enqueue\Client\MessagePriority;
66
use Enqueue\Client\ProducerInterface;
77
use Enqueue\Client\TraceableProducer;
8+
use Enqueue\Util\JSON;
89
use Symfony\Component\HttpFoundation\Request;
910
use Symfony\Component\HttpFoundation\Response;
1011
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
@@ -65,19 +66,13 @@ public function prettyPrintPriority($priority)
6566
}
6667

6768
/**
68-
* @param string $message
69+
* @param mixed $body
6970
*
7071
* @return string
7172
*/
72-
public function prettyPrintMessage($message)
73+
public function ensureString($body)
7374
{
74-
if (is_scalar($message)) {
75-
return htmlspecialchars($message);
76-
}
77-
78-
return htmlspecialchars(
79-
json_encode($message, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
80-
);
75+
return is_string($body) ? $body : JSON::encode($body);
8176
}
8277

8378
/**

pkg/enqueue-bundle/Resources/views/Profiler/panel.html.twig

+5-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@
4444
<td>{{ sentMessage.topic }}</td>
4545
<td style="width: 70%">
4646
<span class="metadata">
47-
<span>{{ sentMessage.body[0:40] }}... </span><a class="btn btn-link text-small sf-toggle" data-toggle-selector="#message-body-{{ loop.index }}" data-toggle-alt-content="Hide trace">Show trace</a>
47+
<span>
48+
{{ collector.ensureString(sentMessage.body)[0:40] }}{% if collector.ensureString(sentMessage.body)[0:40] != collector.ensureString(sentMessage.body) %}.
49+
..{% endif %}
50+
</span>
51+
<a class="btn btn-link text-small sf-toggle" data-toggle-selector="#message-body-{{ loop.index }}" data-toggle-alt-content="Hide trace">Show trace</a>
4852

4953
<div id="message-body-{{ loop.index }}" class="context sf-toggle-content sf-toggle-hidden">
5054
{{ profiler_dump(sentMessage.body) }}

0 commit comments

Comments
 (0)