Opened 16 years ago
Closed 16 years ago
#11073 closed defect (bug) (fixed)
Comment Status for Posts in the Trash
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | normal | Version: | 2.9 |
Component: | Comments | Keywords: | comments, trash, dev-reviewed |
Focuses: | Cc: |
Description
When sending a post to the trash, the status of the comments associated with the post do not get changed. The comments still get counted for the totals displayed in the Right Now module on the Dashboard. The comments are also counted and used for the paging links on the Edit Comments screen, so you end up with empty pages.
When a post is permanently deleted from the trash, the comments do not get deleted. The comments are still counted as explained above.
Tested with r12139
Attachments (5)
Change History (17)
#3
@
16 years ago
Patch introduce wp_trash_post_comments() and wp_untrash_post_comments(). Comments for trashed posts have their status (comment_approved) set to post-trashed. Changing the status allows us to avoid slow joins with the posts table while keeping correct comment counts. A status of "post-trashed" is used instead of "trash" so that comments belonging to a trashed post don't show up in the comment trash. They cannot be restored if their post is trashed so showing them is confusing. The queries in edit-comments.php still use the join on the posts table. I left it there for the moment so that comments whose post was trashed prior to this patch don't show up.
Status for each comment is preserved in an array in postmeta. Status is restored when the post is untrashed. If a comment was in the trash before the post was trashed, it will remain in the trash with its previous state still stored in commentmeta.
#4
@
16 years ago
Using wp_set_comment_status() causes new comment notifications to be sent. It's also slow. I think I'll do some raw updates, maybe do one update per status type in the statuses array.
#5
@
16 years ago
Use direct UPDATEs instead of API to change comment status. Much faster and avoids the state transitions that cause email notifications to be sent.
#6
@
16 years ago
11073.3.diff comments:
_wp_trash_meta_comment_status
should be_wp_trash_meta_comments_status
as it is for more than one comment.- Code has a race condition between collecting the comments to be post_trashed and the post_trashing - any comments which arrive between that period will have there status lost which could be an issue on high volume sites - they would lost on restore as we treat the post_meta as gold
The right now counts being off are due to [12116]. The query that gets the counts right is very slow. This might also be affecting the paging.