8000 [WebProfiler][Translator] Fix TranslationDataCollector should use clo… · Padam87/symfony@07cdfd5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 07cdfd5

Browse files
committed
[WebProfiler][Translator] Fix TranslationDataCollector should use cloneVar
1 parent b5520e9 commit 07cdfd5

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@
183183

184184
<div id="parameters-{{ loop.index }}" class="hidden">
185185
{% for parameters in message.parameters %}
186-
{{ profiler_dump(parameters) }}
187-
{% if not loop.last %}<br />{% endif %}
186+
{{ profiler_dump(parameters, maxDepth=1) }}
188187
{% endfor %}
189188
</div>
190189
{% endif %}

src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ private function sanitizeCollectedMessages($messages)
101101

102102
if (!isset($result[$messageId])) {
103103
$message['count'] = 1;
104-
$message['parameters'] = !empty($message['parameters']) ? array($message['parameters']) : array();
104+
$message['parameters'] = !empty($message['parameters']) ? array($this->cloneVar($message['parameters'])) : array();
105105
$messages[$key]['translation'] = $this->sanitizeString($message['translation']);
106106
$result[$messageId] = $message;
107107
} else {
108108
if (!empty($message['parameters'])) {
109-
$result[$messageId]['parameters'][] = $message['parameters'];
109+
$result[$messageId]['parameters'][] = $this->cloneVar($message['parameters']);
110110
}
111111

112112
++$result[$messageId]['count'];

src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Translation\DataCollectorTranslator;
1515
use Symfony\Component\Translation\DataCollector\TranslationDataCollector;
16+
use Symfony\Component\VarDumper\Cloner\VarCloner;
1617

1718
class TranslationDataCollectorTest extends \PHPUnit_Framework_TestCase
1819
{
@@ -39,6 +40,8 @@ public function testCollectEmptyMessages()
3940

4041
public function testCollect()
4142
{
43+
$cloner = new VarCloner();
44+
4245
$collectedMessages = array(
4346
array(
4447
'id' => 'foo',
@@ -115,9 +118,9 @@ public function testCollect()
115118
'state' => DataCollectorTranslator::MESSAGE_MISSING,
116119
'count' => 3,
117120
'parameters' => array(
118-
array('%count%' => 3),
119-
array('%count%' => 3),
120-
array('%count%' => 4, '%foo%' => 'bar'),
121+
$cloner->cloneVar(array('%count%' => 3)),
122+
$cloner->cloneVar(array('%count%' => 3)),
123+
$cloner->cloneVar(array('%count%' => 4, '%foo%' => 'bar')),
121124
),
122125
'transChoiceNumber' => 3,
123126
),

0 commit comments

Comments
 (0)
0