diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncTest.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncTest.php index b6717ba..ac501c8 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncTest.php +++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncTest.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\entity\Tests\EntityTranslationSyncTest. + * Contains \Drupal\entity\Tests\EntityTranslationSyncTest. */ namespace Drupal\translation_entity\Tests; @@ -52,9 +52,6 @@ public static function getInfo() { ); } - /** - * Overrides \Drupal\simpletest\WebTestBase::setUp(). - */ function setUp() { parent::setUp(); diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/translation_entity/translation_entity.module index f3ea090..6a16455 100644 --- a/core/modules/translation_entity/translation_entity.module +++ b/core/modules/translation_entity/translation_entity.module @@ -645,7 +645,7 @@ function translation_entity_field_extra_fields() { } /** - * Implements hook_form_FORM_ID_alter(). + * Implements hook_form_FORM_ID_alter() for field_ui_field_settings_form(). */ function translation_entity_form_field_ui_field_settings_form_alter(array &$form, array &$form_state, $form_id) { $field = $form['#field']; @@ -737,12 +737,15 @@ function translation_entity_field_attach_presave(EntityInterface $entity) { * language code of the original values. Defaults to FALSE. */ function translation_entity_sync(EntityInterface $entity, $sync_langcode, $original_langcode = FALSE) { - $translations = $entity->getTranslationLanguages(); + $include_default = FALSE; + $translations = $entity->getTranslationLanguages($include_default); + $count_translations = count($translations); - // If we are creating a new entity, or if we have no translations for the - // current entity, or we have no information about the translation being - // saved, then there is nothing to synchronize. - if (empty($sync_langcode) || $entity->isNew() || (count($translations) < 2 && !$original_langcode)) { + // If we have no information about what to sync to, if we are creating a new + // entity, if we have no translations for the current entity, or we have no + // information about the translation being saved, then there is nothing to + // synchronize. + if (empty($sync_langcode) || $entity->isNew() || ($count_translations) < 1) || ($count_translations >= 1) && !$original_langcode)) { return; } @@ -760,8 +763,8 @@ function translation_entity_sync(EntityInterface $entity, $sync_langcode, $origi foreach ($instances as $field_name => $instance) { $field = field_info_field($field_name); - // If the field is empty there is nothing to synchronize. Synchronization - // makes sense only for translatable fields. + // Sync when the field is not empty, when the synchronization translations + // setting is set, and the field is translatable. if (!empty($entity->{$field_name}) && !empty($instance['settings']['translation_sync']) && field_is_translatable($entity_type, $field)) { $columns = isset($field['settings']['translation_sync']) ? $field['settings']['translation_sync'] : array(); $change_map = array();