diff --git a/pathauto.module b/pathauto.module index d1faa47..8518d6b 100644 --- a/pathauto.module +++ b/pathauto.module @@ -97,7 +97,7 @@ function pathauto_entity_update(EntityInterface $entity) { * Implements hook_entity_delete(). */ function pathauto_entity_delete(EntityInterface $entity) { - if ($entity->hasLinkTemplate('canonical') && $entity instanceof ContentEntityInterface && $entity->hasField('path') && $entity->getFieldDefinition('path')->getType() == 'path') { + if ($entity->hasLinkTemplate('canonical') && $entity instanceof ContentEntityInterface && $entity->hasField('path') && $entity->getFieldDefinition('path')->getType() == 'path' && $entity->toUrl('canonical')->isRouted()) { \Drupal::service('pathauto.alias_storage_helper')->deleteEntityPathAll($entity); $entity->get('path')->first()->get('pathauto')->purge(); }