Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#55309 new defect (bug)

Incorrect post comment count after deleting comment with replies

Reported by: jwz's profile jwz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.9.1
Component: Comments Keywords: dev-feedback
Focuses: Cc:

Description

If you move a comment to the trash, and that comment has sub-comments, none of those comments are visible (which is desired) but post->comment_count is reduced by 1 rather than by the total number of comments that have now been hidden.

For example: post has 1 comment with 3 replies. Comment count is 4. Delete the first comment. Now no comments are visible but comment count is 3.

The first comment has comment_approved set to 'trash' but the other 3 comments are still '1'. Perhaps the right fix is that when trashing a comment, all of its sub-comments are also trashed explicitly rather than implicitly.

Change History (1)

#1 @davidbaumwald
2 years ago

  • Keywords dev-feedback added

@jwz I'm going to tag this for dev-feedback to see if a conversation can be sparked to determine _if_ this should be done. I agree, it seems reasonable since those comments are no longer visible.

In the interim, you could always filter the number of comments for each post when the count is updated by using the pre_wp_update_comment_count_now hook and checking the parent comment of each child comment's status.

Note: See TracTickets for help on using tickets.