Ticket #2681: orphan_attachments2.patch

File orphan_attachments2.patch, 0.7 kB (added by ryanscheuermann, 3 years ago)

Patch update: when deleting posts, parent_post should inherit attachments

  • wp-includes/functions-post.php

    old new  
    579579        if ( 'page' == $post->post_type ) 
    580580                $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_type = 'page'"); 
    581581 
     582        $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_type = 'attachment'"); 
     583 
    582584        $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid"); 
    583585 
    584586        $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = $postid");