diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index 43123b7a..b66e80e4 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -193,6 +193,14 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti $comments = $comment_storage->loadMultiple($child_cids); $comment_storage->delete($comments); + // Always invalidate the cache tag for the commented entity. + /** @var \Drupal\comment\CommentInterface $entity */ + foreach ($entities as $entity) { + if ($commented_entity = $entity->getCommentedEntity()) { + Cache::invalidateTags($commented_entity->getCacheTagsToInvalidate()); + } + } + foreach ($entities as $entity) { \Drupal::service('comment.statistics')->update($entity); }