Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#20108 closed defect (bug) (fixed)

Comment counts not updated from edit-form-comment.php

Reported by: dllh's profile dllh Owned by: westi's profile westi
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.4
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

Repro:

  1. On a site with some comments, visit the comments listing page in the admin.
  2. Observe the comment count on a post with several comments.
  3. Click to edit one of the comments and approve it or mark as spam as part of the edit.
  4. Observe the comment count for the post on the comments listing page again.

Expected Result: The comment count will increment or decrement.

Actual Result: The comment count doesn't change.

Further info: Because the ajax links on the listing page use a different method for updating the counts, these links work.

This is caused by the omission of an "echo" statement in edit-form-comment.php. This prevents the value that includes the comment_post_ID from being printed, which in turn causes the comment count to fail to update.

Specifically, in wp_update_comment_count() in wp-includes/comment.php, there's a check for deferred comment counting whose "elseif" checks for $post_id. If $post_id isn't found (it'll be "" thanks to this bug), then wp_update_comment_count_now() never fires.

Compare line 22 of edit-form-comments.php, which prints the comment_ID hidden field, to the line just below, which should print the comment_post_ID field. The first includes an echo that the second omits.

The attached patch adds the echo, which resolves the problem.

This dates back to [19612], in which some tidying up resulted in the dropped value. This so far appears in trunk only but might be nice to fix before the next release.

Attachments (1)

edit-form-comment.php.patch (770 bytes) - added by dllh 13 years ago.
Adds omitted echo statement

Download all attachments as: .zip

Change History (3)

@dllh
13 years ago

Adds omitted echo statement

#1 @westi
13 years ago

  • Milestone changed from Awaiting Review to 3.4
  • Version set to trunk

Great find.

Patch looks good to me.

#2 @westi
13 years ago

  • Owner set to westi
  • Resolution set to fixed
  • Status changed from new to closed

In [19981]:

Make sure to echo out the comment_post_ID when building the edit comment form otherwise the post comment counts will get out of sync. Fixes #20108 props dllh.

Note: See TracTickets for help on using tickets.