diff --git a/core/modules/path/path.module b/core/modules/path/path.module index a182214dab..328c434c33 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -5,6 +5,7 @@ * Enables users to rename URLs. */ +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Form\FormStateInterface; @@ -76,3 +77,17 @@ function path_entity_base_field_info(EntityTypeInterface $entity_type) { return $fields; } } + +/** + * Implements hook_entity_revision_delete(). + */ +function path_entity_revision_delete(EntityInterface $entity) { + $entity_type_id = $entity->getEntityTypeId(); + $source = str_replace('{' . $entity_type_id . '}', $entity->id(), $entity->getEntityType()->getLinkTemplate('revision')); + $source = str_replace('{' . $entity_type_id . '_revision}', '%', $source); + $revisionable_conditions = [ + 'source' => $source, + 'langcode' => $entity->language()->getId(), + ]; + \Drupal::service('path.alias_storage')->delete($revisionable_conditions); +}