diff --git a/pathauto.module b/pathauto.module index d0763fa..97cb022 100644 --- a/pathauto.module +++ b/pathauto.module @@ -98,12 +98,16 @@ function pathauto_entity_update(EntityInterface $entity) { } /** - * Implements hook_entity_update(). + * Implements hook_entity_delete(). */ function pathauto_entity_delete(EntityInterface $entity) { if ($entity->hasLinkTemplate('canonical') && $entity instanceof ContentEntityInterface && $entity->hasField('path')) { \Drupal::service('pathauto.alias_storage_helper')->deleteEntityPathAll($entity); - $entity->path->first()->get('pathauto')->purge(); + + // Remove pathauto state. + $collection = 'pathauto_state.' . $entity->getEntityTypeId(); + \Drupal::keyValue($collection) + ->delete($entity->Id()); } }