change post_parent on orphaned attachments. props ryanscheuermann. fixes #2681

git-svn-id: https://develop.svn.wordpress.org/trunk@4601 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2006-12-04 14:25:21 +00:00
parent bb18d08ce4
commit f2659c992f
1 changed files with 2 additions and 0 deletions

View File

@ -410,6 +410,8 @@ function wp_delete_post($postid = 0) {
if ( 'page' == $post->post_type )
$wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_type = 'page'");
$wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_type = 'attachment'");
$wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid");
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = $postid");