diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 5e10c11..6631707 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -591,18 +591,7 @@ function content_translation_field_language_alter(&$display_language, $context) foreach ($entity->translation as $langcode => $translation) { if ($langcode == $context['langcode'] || !content_translation_view_access($entity, $langcode)) { - // Unset unaccessible field translations: if the field is untranslatable - // unsetting a language different from Language::LANGCODE_NOT_SPECIFIED has no - // effect. - foreach ($instances as $instance) { - // @todo BC entities have the same value accessibile both with the - // entity language and with Language::LANGCODE_DEFAULT. We need need to unset - // both until we remove the BC layer. - if ($langcode == $entity_langcode) { - unset($entity->{$instance['field_name']}[Language::LANGCODE_DEFAULT]); - } - unset($entity->{$instance['field_name']}[$langcode]); - } + $entity->removeTranslation($langcode); } } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php index 77ac782..016fe01 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php @@ -235,8 +235,11 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac // A new translation is not available in the translation metadata, hence // it should count as one more. $published = $new_translation; - foreach ($entity->translation as $translation) { - $published += $translation['status']; + // When creating a brand new translation, $entity->translation is not set. + if (!($new_translation)) { + foreach ($entity->translation as $translation) { + $published += $translation['status']; + } } $enabled = $published > 1; }