WordPress.org

Make WordPress Core

Ticket #16391: 16391.3.diff

File 16391.3.diff, 1.6 KB (added by SergeyBiryukov, 6 years ago)
  • wp-includes/post.php

     
    204204                return false;
    205205
    206206        $file = apply_filters( 'update_attached_file', $file, $attachment_id );
    207         $file = _wp_relative_upload_path($file);
    208 
    209         return update_post_meta( $attachment_id, '_wp_attached_file', $file );
     207        if ( $file = _wp_relative_upload_path( $file ) )
     208                return update_post_meta( $attachment_id, '_wp_attached_file', $file );
     209        else
     210                return delete_post_meta( $attachment_id, '_wp_attached_file' );
    210211}
    211212
    212213/**
     
    40164017        if ( !$post = get_post( $post_id ) )
    40174018                return false;
    40184019
    4019         $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID );
    4020 
    4021         return update_post_meta( $post->ID, '_wp_attachment_metadata', $data);
     4020        if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
     4021                return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
     4022        else
     4023                return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
    40224024}
    40234025
    40244026/**
     
    52185220        $post = get_post( $post );
    52195221        $thumbnail_id = absint( $thumbnail_id );
    52205222        if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
    5221                 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' );
    5222                 if ( ! empty( $thumbnail_html ) ) {
     5223                if ( $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
    52235224                        return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
    5224                 }
     5225                else
     5226                        return delete_post_meta( $post->ID, '_thumbnail_id' );
    52255227        }
    52265228        return false;
    52275229}