Skip to content

Commit

Permalink
Fix endless loop akeneo
Browse files Browse the repository at this point in the history
  • Loading branch information
vhrychenko committed Feb 26, 2019
1 parent c6bb753 commit 5d2e136
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function translate($value, array $payload)
{
$this->initAttributeOptionMap();

foreach ($value as $attributeKey => &$attributeValues) {
foreach ($value as $attributeKey => $attributeValues) {
if ($this->isKeySkipped($attributeKey)) {
unset($value[$attributeKey]);
continue;
Expand All @@ -77,7 +77,7 @@ public function translate($value, array $payload)

$isAttributeLocalizable = $this->isAttributeLocalizable($attributeKey);

foreach ($attributeValues as &$attributeValue) {
foreach ($attributeValues as $index => $attributeValue) {
$attributeData = $attributeValue[static::KEY_DATA];
$locale = $attributeValue[static::KEY_LOCALE];

Expand All @@ -86,18 +86,14 @@ public function translate($value, array $payload)
continue 2;
}

// if (count($attributeData) === 0) {
// continue;
// }

if ($isAttributeLocalizable) {
$options = is_array($attributeData) ? $this->getArrayOptions($attributeKey, $attributeData) : $this->getOptions($attributeKey, $attributeData);
if (!array_key_exists($locale, $options)) {
unset($value[$attributeKey]);
continue;
}

$attributeValue[static::KEY_DATA] = $options[$locale];
$value[$attributeKey][$index][static::KEY_DATA] = $options[$locale];
continue;
}

Expand Down

0 comments on commit 5d2e136

Please sign in to comment.