diff --git a/core/lib/Drupal/Core/Entity/EntityChangedInterface.php b/core/lib/Drupal/Core/Entity/EntityChangedInterface.php index 8f57863d94..a28fe16850 100644 --- a/core/lib/Drupal/Core/Entity/EntityChangedInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityChangedInterface.php @@ -37,9 +37,10 @@ public function setChangedTime($timestamp); /** * Gets the timestamp of the last entity change across all translations. * - * This method will return the highest timestamp across all translations. If - * you need to check that no translation was changed after a certain time, you - * have to check each translation's timestamp individually. + * This method will return the highest timestamp across all translations. To + * check that no translation is older than in another version of the entity + * (e.g. to avoid overwriting newer translations with old data), compare each + * translation to the other version individually. * * @return int * The timestamp of the last entity save operation across all diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php index 271e24def2..6bb7665d3a 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php @@ -18,18 +18,18 @@ public function validate($entity, Constraint $constraint) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ if (!$entity->isNew()) { $saved_entity = \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id()); - // Ensure that all the entity translations match their current version - // in the storage in order to avoid reverting other changes. The entity - // object might contain an older entity translation when a translation - // is being concurrently edited. If the form that is submitted last - // is not yet cached, the entity will be retrieved from the entity - // storage on submit, and that entity object will be the updated one - // from the previous form submission. To prevent the entity from the + // Ensure that all the entity translations are the same as or newer + // than their current version in the storage in order to avoid + // reverting other changes. The entity object that is being saved might + // contain an older entity translation when different translations are + // being concurrently edited. The form that is submitted last will + // retrieve the entity from the storage on submit, and that entity + // object will be the updated one from the previous form submission, + // containing the new saved timestamps. To prevent the entity from the // second submission from being saved and overwriting changes from the - // first, the changed timestamp can be added to the form so that it - // updates the entity object on submit. We use the timestamp to - // determine when a previous entity translation version has been edited - // and is currently being saved. + // first, we use the submmitted translations' timestamps to determine + // when a previous entity translation version has been edited and is + // currently being saved. // @see \Drupal\node\NodeForm::form(). if ($saved_entity) { $common_translation_languages = array_intersect_key($entity->getTranslationLanguages(), $saved_entity->getTranslationLanguages());