Commit adda2c86 authored by plach's avatar plach

Issue #2995655 by awm, Sam152, jedgar1mx, lpeabody, axel.rutz: Invalid...

Issue #2995655 by awm, Sam152, jedgar1mx, lpeabody, axel.rutz: Invalid translation language (und) specified. in Drupal\Core\Entity\ContentEntityBase when changing language of an entity
parent e6f59e07
......@@ -191,6 +191,12 @@ protected function getOriginalEntity(ContentEntityInterface $entity) {
* The original entity translation object.
*/
protected function getOriginalTranslation(ContentEntityInterface $entity, ContentEntityInterface $original) {
// If the language of the default translation is changing, the original
// translation will be the same as the original entity, but they won't
// necessarily have the same langcode.
if ($entity->isDefaultTranslation() && $original->language()->getId() !== $entity->language()->getId()) {
return $original;
}
$langcode = $entity->language()->getId();
if ($original->hasTranslation($langcode)) {
$original_langcode = $langcode;
......
......@@ -367,6 +367,16 @@ public function testFieldSynchronizationAndValidation() {
$this->assertLatestRevisionFieldValues($entity_id, [26, 3, 3, 'Alt 3 EN', 'Alt 4 IT']);
}
/**
* Test changing the default language of an entity.
*/
public function testChangeDefaultLanguageNonTranslatableFieldsHidden() {
$this->setUntranslatableFieldWidgetsDisplay(FALSE);
$entity = $this->saveNewEntity();
$entity->langcode = 'it';
$this->assertCount(0, $entity->validate());
}
/**
* Sets untranslatable field widgets' display status.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment