Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / path / src / Plugin / Validation / Constraint / PathAliasConstraintValidator.php
index e6771f76d2fab7d0e2875f407811a4af52f27aa3..be6350f75b24866cb8fcd01b44ec80a6772c77dd 100644 (file)
@@ -48,8 +48,14 @@ class PathAliasConstraintValidator extends ConstraintValidator implements Contai
     if ($entity && !$entity->isNew() && !$entity->isDefaultRevision()) {
       /** @var \Drupal\Core\Entity\ContentEntityInterface $original */
       $original = $this->entityTypeManager->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id());
-      if ($value->alias != $original->path->alias) {
-        $this->context->addViolation($constraint->message);
+      $entity_langcode = $entity->language()->getId();
+
+      // Only add the violation if the current translation does not have the
+      // same path alias.
+      if ($original->hasTranslation($entity_langcode)) {
+        if ($value->alias != $original->getTranslation($entity_langcode)->path->alias) {
+          $this->context->addViolation($constraint->message);
+        }
       }
     }
   }