WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 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:

  1. Ensure the default yyyy/mm uploads organisation setting is enabled.
  2. Create a post. Set the publish date to 2005/03/xx.
  3. Upload an image to the post, it will be uploaded to wp-content/uploads/2005/03/image.jpg per media_handle_upload(), see [9663]
  4. Export.
  5. 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.

Attachments (1)

16981.importer.diff (1.8 KB) - added by duck_ 4 years ago.

Download all attachments as: .zip

Change History (2)

@duck_4 years ago

comment:1 @duck_4 years ago

  • Resolution set to fixed
  • Status changed from new to closed

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

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.

"Don't think so." -- nacin.

Note: See TracTickets for help on using tickets.