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

WordPress Trac noreply at wordpress.org
Mon Oct 17 15:00:09 UTC 2016


#35593: Metadata from wrong file in media_handle_upload
-------------------------------------------------+-------------------------
 Reporter:  normanrz                             |       Owner:  joemcgill
     Type:  defect (bug)                         |      Status:  reviewing
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Media                                |  Review
 Severity:  normal                               |     Version:
 Keywords:  has-patch needs-testing reporter-    |  Resolution:
  feedback close                                 |     Focuses:
                                                 |  administration
-------------------------------------------------+-------------------------

Comment (by normanrz):

 Hi @joemcgill,
 thanks for looking into this and sorry for the long wait.
 I think the problem is that when I use the drag&drop feature to upload
 files the following is happening:
 - `media_handle_upload` is invoked and creates the `$file` variable
 - `media_handle_upload` calls `wp_insert_attachment` which then calls the
 `add_attachment` hook
 - now my plugin changes filename (and in fact calls
 `wp_update_attachment_metadata`)
 - the plugin returns to `wp_insert_attachment` and that returns to
 `media_handle_upload`
 - finally `media_handle_upload` invokes `wp_update_attachment_metadata`
 again, but with the stale `$file` object (because my plugin actually
 changed some of the metadata) which it created before

 It seems to me that I can't handle this in the plugin because any metadata
 will be later overriden by the stale information from
 `media_handle_upload`.

 Thanks
 Norman

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


More information about the wp-trac mailing list