diff --git a/core/modules/content_translation/src/FieldTranslationSynchronizer.php b/core/modules/content_translation/src/FieldTranslationSynchronizer.php index bd85384e7b..5e97aa3fad 100644 --- a/core/modules/content_translation/src/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/src/FieldTranslationSynchronizer.php @@ -92,16 +92,16 @@ public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode $force_sync = FALSE; if ($entity->isDefaultTranslationAffectedOnly()) { - // If changes to untranslatable fields affect are configured to affect - // only the default revision translation, we need to skip synchronization - // is pending revisions, otherwise multiple revision translations would be + // If changes to untranslatable fields are configured to affect only the + // default revision translation, we need to skip synchronization in + // pending revisions, otherwise multiple revision translations would be // affected. if (!$entity->isDefaultRevision()) { return; } // When saving a default revision for a non-default translation, we need - // to make sure that we reconcile any previous changes in the default - // translation. + // to make sure that we enforce synchronization of any previous changes in + // the default translation. elseif (!$entity->isDefaultTranslation()) { $sync_langcode = $entity->getUntranslated()->language()->getId(); $force_sync = TRUE; @@ -165,14 +165,14 @@ public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode } /** - * Ensures that field values are actually synchronized. + * Syncs the field values of all specified columns. * * @param array[] $field_values * The field values to be synchronized. * @param string $sync_langcode - * The - * - * @param array $columns + * The language code of the items to use as source values. + * @param string[] $columns + * An array of column names. */ protected function enforceSynchronization(array &$field_values, $sync_langcode, array $columns) { $source_items = $field_values[$sync_langcode]; diff --git a/core/modules/content_translation/src/Plugin/Validation/Constraint/ContentTranslationSynchronizedFieldsConstraintValidator.php b/core/modules/content_translation/src/Plugin/Validation/Constraint/ContentTranslationSynchronizedFieldsConstraintValidator.php index 49603e0e09..4edb2d2fc7 100644 --- a/core/modules/content_translation/src/Plugin/Validation/Constraint/ContentTranslationSynchronizedFieldsConstraintValidator.php +++ b/core/modules/content_translation/src/Plugin/Validation/Constraint/ContentTranslationSynchronizedFieldsConstraintValidator.php @@ -17,14 +17,14 @@ * * As for untranslatable fields, two modes are supported: * - When changes to untranslatable fields are configured to affect all revision - * translations, synchronized field properties can be changed only in default + * translations, synchronized field columns can be changed only in default * revisions. * - When changes to untranslatable fields affect are configured to affect only - * the default revision translation, synchronized field properties can be + * the revision's default translation, synchronized field columns can be * changed only when editing the default translation. This may lead to * temporarily desynchronized values, when saving a pending revision for the - * default translation that changes a synchronized property. These are - * reconciled when saving changes to the default translation as the new + * default translation that changes a synchronized column. These are actually + * synchronized when saving changes to the default translation as a new * default revision. * * @see \Drupal\content_translation\Plugin\Validation\Constraint\ContentTranslationSynchronizedFieldsConstraint @@ -110,7 +110,7 @@ public function validate($value, Constraint $constraint) { /** @var \Drupal\Core\Entity\ContentEntityInterface $original */ $original = $this->synchronizer->getOriginalEntity($entity); $original_translation = $this->getOriginalTranslation($entity, $original); - $has_changes = $this->hasSynchronizedPropertyChanges($entity, $original_translation, $settings); + $has_changes = $this->hasSynchronizedColumnChanges($entity, $original_translation, $settings); if ($entity->isDefaultTranslationAffectedOnly()) { if (!$entity->isDefaultTranslation()) { @@ -124,7 +124,7 @@ public function validate($value, Constraint $constraint) { if ($langcode !== $active_langcode) { $translation = $entity->getTranslation($langcode); $original_translation = $this->getOriginalTranslation($entity, $original); - if ($this->hasSynchronizedPropertyChanges($translation, $original_translation, $settings)) { + if ($this->hasSynchronizedColumnChanges($translation, $original_translation, $settings)) { $this->context->addViolation($constraint->message); break; } @@ -139,7 +139,7 @@ public function validate($value, Constraint $constraint) { } /** - * Checks whether any synchronized property has changes. + * Checks whether any synchronized column has changes. * * @param \Drupal\Core\Entity\ContentEntityInterface $entity * The entity being validated. @@ -151,21 +151,21 @@ public function validate($value, Constraint $constraint) { * * @return bool */ - protected function hasSynchronizedPropertyChanges(ContentEntityInterface $entity, ContentEntityInterface $original, array $settings) { + protected function hasSynchronizedColumnChanges(ContentEntityInterface $entity, ContentEntityInterface $original, array $settings) { $field_definitions = $entity->getFieldDefinitions(); foreach ($settings as $field_name => $field_synchronization_settings) { foreach ($field_synchronization_settings as $group => $translatable) { if (!$translatable && isset($field_definitions[$field_name])) { $field_type_definition = $this->fieldTypeManager->getDefinition($field_definitions[$field_name]->getType()); - foreach ($field_type_definition['column_groups'][$group]['columns'] as $property) { + foreach ($field_type_definition['column_groups'][$group]['columns'] as $column) { $items = $entity->get($field_name)->getValue(); $original_items = $original->get($field_name)->getValue(); if (count($items) !== count($original_items)) { return TRUE; } foreach ($items as $delta => $item) { - if ($items[$delta][$property] != $original_items[$delta][$property]) { + if ($items[$delta][$column] != $original_items[$delta][$column]) { return TRUE; } } diff --git a/core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncValidationTest.php b/core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncValidationTest.php index 30dee9dc56..2ea3436df2 100644 --- a/core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncValidationTest.php +++ b/core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncValidationTest.php @@ -119,11 +119,11 @@ protected function setUp() { * @covers ::__construct * @covers ::create * @covers ::validate - * @covers ::hasSynchronizedPropertyChanges + * @covers ::hasSynchronizedColumnChanges */ public function testPendingRevisionValidation() { // Test that when untranslatable field widgets are displayed, synchronized - // field properties can be changed only in default revisions. + // field columns can be changed only in default revisions. $this->setUntranslatableFieldWidgetsDisplay(TRUE); $entity = $this->saveNewEntity(); $entity_id = $entity->id(); @@ -187,10 +187,10 @@ public function testPendingRevisionValidation() { $this->assertLatestRevisionFieldValues($entity_id, [7, 6, 6, 'Alt 6 EN', 'Alt 7 IT']); // Test that when untranslatable field widgets are hidden, synchronized - // field properties can be changed only when editing the default - // translation. This may lead to temporarily desynchronized values, when - // saving a pending revision for the default translation that changes a - // synchronized property (see revision 11). + // field columns can be changed only when editing the default translation. + // This may lead to temporarily desynchronized values, when saving a pending + // revision for the default translation that changes a synchronized column + // (see revision 11). $this->setUntranslatableFieldWidgetsDisplay(FALSE); $entity = $this->saveNewEntity(); $entity_id = $entity->id();