WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#12766 closed defect (bug) (fixed)

commentmeta data orphaned when deleting a post from the trash

Reported by: briancolinger Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version:
Component: Comments Keywords: has-patch needs-testing
Focuses: Cc:

Description

Adding $force_delete param to wp_delete_comment().
wp_delete_post() will now delete each comment individually using wp_delete_comment() with the $force_delete param set to true.

This fixes and issue where related commentmeta is orphaned when deleting a post from the trash.

Attachments (3)

post.php (1.1 KB) - added by briancolinger 4 years ago.
comment.php (1.1 KB) - added by briancolinger 4 years ago.
commentmeta.patch (1.9 KB) - added by briancolinger 4 years ago.

Download all attachments as: .zip

Change History (12)

briancolinger4 years ago

briancolinger4 years ago

comment:1 briancolinger4 years ago

  • Cc briancolinger@… added

comment:2 nacin4 years ago

  • Milestone changed from Unassigned to 3.0

Also, #11470

comment:3 ryan4 years ago

Why the switch to post_parent. Seems that would delete comments from the wrong post.

comment:4 briancolinger4 years ago

@ryan, you are correct, that seems to be a data loss bug. I'll fix it and re-post a patch.

comment:5 dd324 years ago

  • Keywords needs-patch added

briancolinger4 years ago

comment:6 briancolinger4 years ago

I've switched back to $postid instead of post_parent. I've tested this patch and it does not cause comments from the wrong post to be deleted like the last patch did!

Is it possible for someone to delete the comment.php and post.php patches that i submitted earlier?

comment:7 rmccue4 years ago

  • Cc me@… added
  • Keywords has-patch needs-testing added; needs-patch removed

comment:8 nacin4 years ago

(In [13995]) Add $force_delete to wp_delete_comment(). see #12766, see #11470.

comment:9 nacin4 years ago

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

(In [13997]) Use the API to remove comments when deleting a post. Cleans up comment meta in the process. fixes #12766, props briancolinger

Note: See TracTickets for help on using tickets.