[wp-trac] [WordPress Trac] #35593: Metadata from wronge file in media_handle_upload

WordPress Trac noreply at wordpress.org
Sun Jan 24 15:14:22 UTC 2016


#35593: Metadata from wronge file in media_handle_upload
----------------------------+-----------------------------
 Reporter:  normanrz        |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Media           |    Version:  trunk
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 In media_handle_upload and media_handle_sideload the attachment metadata
 is generated after inserting the attachment. For that the same file name
 is used. However, if a plugin changes the filename in an 'add_attachment'
 hook the wrong file name will be used. Thus the wrong metadata is written
 or it is cleared.

 See wp-admin/includes/media.php:
 {{{
 368             // Save the data
 369             $id = wp_insert_attachment($attachment, $file, $post_id);
 370             if ( !is_wp_error($id) ) {
 371                     wp_update_attachment_metadata( $id,
 wp_generate_attachment_metadata( $id, $file ) );
 372             }
 }}}

 In my patch I query the filename again before updating the metadata.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35593>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list