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

WordPress Trac noreply at wordpress.org
Mon Jan 25 08:52:56 UTC 2016


#35593: Metadata from wrong file in media_handle_upload
-------------------------------------+------------------------------
 Reporter:  normanrz                 |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Media                    |     Version:  trunk
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  administration
-------------------------------------+------------------------------
Changes (by swissspidy):

 * keywords:   => has-patch needs-testing


Old description:

> 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.

New description:

 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#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list