#2836 closed defect (bug) (fixed)
wp_delete_comment() uses simple comment count decrementation instead of getting a fresh count
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.0.3 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
wp_delete_comment() decrements the comment count for its parent post by subtracting 1 from the current count. This perpetuates errors created by older plugins. It also doesn't jive with comment creation, in which a fresh count is made.
Maybe in a year or two, after plugins have been all updated to use the API functions, we can go back to simple incrementation/decrementation (which is faster, and saves a query), but for now, we should try to minimize comment count errors and do a fresh count on every change.
I'll be uploading patches for trunk and the 2.0 branch shortly.
Attachments (2)
Change History (7)
#1
@
19 years ago
- Keywords has-patch added
- Status changed from new to assigned
The patch for the 2.0 branch is simple: instead of blindly decrementing, it does a fresh count, identical to the way it does in wp_insert_comment()
The patch for Trunk is a little more comprehensive. I wrote a new function, wp_update_comment_count() which takes a post ID and does the COUNT() and the UPDATE queries, as well as filling in an entry for the comment count cache array. wp_insert_comment(), wp_delete_comment() and wp_update_comment() have all been edited to use this function.
patch for /branches/2.0/