Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bug #20700 [WebProfilerBundle][Translator] Fix TranslationDataCollect…
…or should use cloneVar (ogizanagi)

This PR was merged into the 3.2 branch.

Discussion
----------

[WebProfilerBundle][Translator] Fix TranslationDataCollector should use cloneVar

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes?
| New feature?  | no?
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

Was missed in #19614 ?

### Before

![capture d ecran 2016-11-30 a 15 45 33](https://cloud.githubusercontent.com/assets/2211145/20756865/9a416934-b714-11e6-9cb5-890a6222b6fa.png)

### After

![capture d ecran 2016-11-30 a 15 43 58](https://cloud.githubusercontent.com/assets/2211145/20756877/9efaccae-b714-11e6-9523-b3f8f2e4bd8c.png)

Commits
-------

07cdfd5 [WebProfiler][Translator] Fix TranslationDataCollector should use cloneVar
  • Loading branch information
fabpot committed Dec 2, 2016
2 parents 0c1e9ab + 07cdfd5 commit f8b2a18
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Expand Up @@ -183,8 +183,7 @@

<div id="parameters-{{ loop.index }}" class="hidden">
{% for parameters in message.parameters %}
{{ profiler_dump(parameters) }}
{% if not loop.last %}<br />{% endif %}
{{ profiler_dump(parameters, maxDepth=1) }}
{% endfor %}
</div>
{% endif %}
Expand Down
Expand Up @@ -101,12 +101,12 @@ private function sanitizeCollectedMessages($messages)

if (!isset($result[$messageId])) {
$message['count'] = 1;
$message['parameters'] = !empty($message['parameters']) ? array($message['parameters']) : array();
$message['parameters'] = !empty($message['parameters']) ? array($this->cloneVar($message['parameters'])) : array();
$messages[$key]['translation'] = $this->sanitizeString($message['translation']);
$result[$messageId] = $message;
} else {
if (!empty($message['parameters'])) {
$result[$messageId]['parameters'][] = $message['parameters'];
$result[$messageId]['parameters'][] = $this->cloneVar($message['parameters']);
}

++$result[$messageId]['count'];
Expand Down
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Translation\DataCollectorTranslator;
use Symfony\Component\Translation\DataCollector\TranslationDataCollector;
use Symfony\Component\VarDumper\Cloner\VarCloner;

class TranslationDataCollectorTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -39,6 +40,8 @@ public function testCollectEmptyMessages()

public function testCollect()
{
$cloner = new VarCloner();

$collectedMessages = array(
array(
'id' => 'foo',
Expand Down Expand Up @@ -115,9 +118,9 @@ public function testCollect()
'state' => DataCollectorTranslator::MESSAGE_MISSING,
'count' => 3,
'parameters' => array(
array('%count%' => 3),
array('%count%' => 3),
array('%count%' => 4, '%foo%' => 'bar'),
$cloner->cloneVar(array('%count%' => 3)),
$cloner->cloneVar(array('%count%' => 3)),
$cloner->cloneVar(array('%count%' => 4, '%foo%' => 'bar')),
),
'transChoiceNumber' => 3,
),
Expand Down

0 comments on commit f8b2a18

Please sign in to comment.