Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294323

Invalid translation language (und) specified. in Drupal\Core\Entity\ContentEntityBase when changing language of an entity

$
0
0

steps to produce:
0. Clean site install of drupal 8.7 and enable content translation.
1. Add 2 languages to your site
2. Go to admin/config/regional/content-language
3. check content.
4. From the content list select article.
5. Check "hide non translatable fields on translation forms"
6. Create an article.
7. Update the article and change it's language.
8. Save.

Expected result: The language gets updated.

Actual result: Invalid translation language (und) specified. in Drupal\Core\Entity\ContentEntityBase when changing language of an entity.

more infor:

I narrowed down the problem to the "validate" method in ContentTranslationSynchronizedFieldsConstraintValidator.php,

    if ($entity->isDefaultRevision() && !$entity->isDefaultTranslationAffectedOnly()) {
      return;
    }

entity->isDefaultTranslationAffectedOnly is returning false because it has this condition:

return !empty($bundle_info[$bundle_name]['untranslatable_fields.default_translation_affected']); 

To fix my issue, I unchecked "Hide non translatable fields on translation forms" for the content types at "admin/config/regional/content-language".
Alternatively I could use this: https://www.drupal.org/node/2938191.

That said, I am not sure why setting $entity->isDefaultTranslationAffectedOnly() is relying on

$bundle_info[$bundle_name]['untranslatable_fields.default_translation_affected']

Update

I digged more into the problem and it seems that

$original_translation = $this->getOriginalTranslation($entity, $original);

calls:

$original->getTranslation($original_langcode);

But langcode is "und" and there are no translations so the exception is thrown.

This also happens when changing the language on a published node and also changing it's workflow state to draft.


Viewing all articles
Browse latest Browse all 294323

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>