WordPress.org

Make WordPress Core

Ticket #36437: 36437.patch

File 36437.patch, 720 bytes (added by thorbrink, 3 years ago)
  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index 9cf0c16..b0ca5ae 100644
    function wp_delete_attachment( $post_id, $force_delete = false ) { 
    47164716         */
    47174717        do_action( 'delete_attachment', $post_id );
    47184718
    4719         wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
    4720         wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type));
     4719        if ( ( ! empty( $attachment_taxonomies = get_object_taxonomies( $post->post_type ) ) ) ) {
     4720                wp_delete_object_term_relationships( $post_id, $attachment_taxonomies );
     4721        }
    47214722
    47224723        // Delete all for any posts.
    47234724        delete_metadata( 'post', null, '_thumbnail_id', $post_id, true );