Skip to content

Commit aae98a9

Browse files
committed
bug #14195 [Translation][Profiler] fixed infiinite loop when collect msg from fallback (aitboudad)
This PR was merged into the 2.7 branch. Discussion ---------- [Translation][Profiler] fixed infiinite loop when collect msg from fallback | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Fixed tickets | ~ | Tests pass? | yes | License | MIT Commits ------- 59f2172 [Translation][Profiler] fixed infiinite loop when collect msg from fallback.
2 parents 8e74cfa + 59f2172 commit aae98a9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Symfony/Component/Translation/DataCollectorTranslator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ private function collectMessage($locale, $domain, $id, $translation)
137137
$locale = $fallbackCatalogue->getLocale();
138138
break;
139139
}
140+
141+
$fallbackCatalogue = $fallbackCatalogue->getFallBackCatalogue();
140142
}
141143
} else {
142144
$state = self::MESSAGE_MISSING;

src/Symfony/Component/Translation/Tests/DataCollectorTranslatorTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ protected function setUp()
2626
public function testCollectMessages()
2727
{
2828
$collector = $this->createCollector();
29-
$collector->setFallbackLocales(array('fr'));
29+
$collector->setFallbackLocales(array('fr', 'ru'));
3030

3131
$collector->trans('foo');
3232
$collector->trans('bar');
3333
$collector->transChoice('choice', 0);
34+
$collector->trans('bar_ru');
3435

3536
$expectedMessages = array();
3637
$expectedMessages[] = array(
@@ -54,6 +55,13 @@ public function testCollectMessages()
5455
'domain' => 'messages',
5556
'state' => DataCollectorTranslator::MESSAGE_MISSING,
5657
);
58+
$expectedMessages[] = array(
59+
'id' => 'bar_ru',
60+
'translation' => 'bar (ru)',
61+
'locale' => 'ru',
62+
'domain' => 'messages',
63+
'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK,
64+
);
5765

5866
$this->assertEquals($expectedMessages, $collector->getCollectedMessages());
5967
}
@@ -64,6 +72,7 @@ private function createCollector()
6472
$translator->addLoader('array', new ArrayLoader());
6573
$translator->addResource('array', array('foo' => 'foo (en)'), 'en');
6674
$translator->addResource('array', array('bar' => 'bar (fr)'), 'fr');
75+
$translator->addResource('array', array('bar_ru' => 'bar (ru)'), 'ru');
6776

6877
$collector = new DataCollectorTranslator($translator);
6978

0 commit comments

Comments
 (0)