Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#7707 closed defect (bug) (fixed)

WXR Import can generate orphan postmeta entries

Reported by: dougal's profile dougal Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version:
Component: Administration Keywords: importer, wxr, wordpress, import, postmeta, meta, has-patch
Focuses: Cc:

Description

There is a bug in the duplicate post detection of the WordPress WXR importer. The creation of postmeta occurs outside of the if branch which detects whether a post is a duplicate. I assume that this is in order to attach additional metadata to the copy of the post already in the database (which could be due to re-starting a previously interrupted import). However, due to the way the code is structured, the $post_id variable is not set in this case, and so the postmeta entries are assigned to post_id=0 (zero).

The solution is to capture the post_id returned from the post_exists() function, and set the $post_id variable in the other branch of the duplicate post test.

Attachments (1)

wordpress.php.diff (387 bytes) - added by dougal 16 years ago.
Set $post_id properly for duplicate posts

Download all attachments as: .zip

Change History (4)

@dougal
16 years ago

Set $post_id properly for duplicate posts

#1 @dougal
16 years ago

  • Keywords has-patch added

#2 @dougal
16 years ago

  • Cc ryan westi added

Bump. Would really like a fix for this to go into 2.7.

Can supply WXR files for testing, if needed. Though, all you really need for testing is a WXR that has posts with postmeta entries. Just import the same file more than once to trigger the duplicate detection.

#3 @westi
16 years ago

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

(In [8957]) Ensure that post meta is attached to the correct post when importing. Fixes #7707 props dougal.

Note: See TracTickets for help on using tickets.