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

git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@4602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2006-12-04 14:31:09 +00:00
parent 4c99f09227
commit 1a3f75b48a

View File

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