WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 10 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:
PR Number:

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 10 years ago.
comment.php (1.1 KB) - added by briancolinger 10 years ago.
commentmeta.patch (1.9 KB) - added by briancolinger 10 years ago.

Download all attachments as: .zip

Change History (12)

@briancolinger
10 years ago

#1 @briancolinger
10 years ago

  • Cc briancolinger@… added

#2 @nacin
10 years ago

  • Milestone changed from Unassigned to 3.0

Also, #11470

#3 @ryan
10 years ago

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

#4 @briancolinger
10 years ago

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

#5 @dd32
10 years ago

  • Keywords needs-patch added

#6 @briancolinger
10 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?

#7 @rmccue
10 years ago

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

#8 @nacin
10 years ago

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

#9 @nacin
10 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.