Opened 13 years ago
Closed 13 years ago
#16981 closed defect (bug) (fixed)
Importer uploads to incorrect directory
Reported by: | duck_ | Owned by: | |
---|---|---|---|
Milestone: | WordPress.org | Priority: | normal |
Severity: | normal | Version: | |
Component: | Import | Keywords: | has-patch |
Focuses: | Cc: |
Description
In some situations the importer may upload a file to a different directory compared to the export site.
Steps to reproduce:
- Ensure the default yyyy/mm uploads organisation setting is enabled.
- Create a post. Set the publish date to 2005/03/xx.
- Upload an image to the post, it will be uploaded to wp-content/uploads/2005/03/image.jpg per media_handle_upload(), see [9663]
- Export.
- Import on a new site.
The image will be located in wp-content/uploads/2011/03/ (subject to change, it will be the post_date of the attachment, i.e. date of upload).
This occurs because the attachment's post_date, which the importer relies on to set the upload directory, may be different to the folder it is stored in (see media_handle_upload() and [9663] again).
Proposed solution is to attempt to grab the upload location from _wp_attached_file
post meta and fallback to post_date which is correct in most cases.
Do we also want to start setting the post_date of attachments to be the same as the parent post? 'post_date' => $time
in media_handle_upload() and friends.
http://plugins.trac.wordpress.org/changeset/365515/wordpress-importer
For reference looks like this bug has been around since importing attachments was introduced, see [6390].
"Don't think so." -- nacin.