humanmade / WordPress-Importer

In-development rewrite of the WordPress (WXR) Importer
Other
358 stars 63 forks source link

imported posts are not assigned to a post-format when that is speficied in the WXR #122

Open pbiron opened 7 years ago

pbiron commented 7 years ago

When an import contains something like:

<item>
   <wp:post_id>123</wp:post_id>
   ...
   <category domain='post-format' nicename='some-post-format'>Some Post Format</category>
   ...
</item>

The some-post-format term is added (if needed) to the 'post-format' taxonomy, but the post is not associated with that term in the term_relationships table.

I don't understand the code well enough yet to do a fix for this, but it has something to do with WXR_Importer::process_post(). As it loops thru the terms for an imported post it does the following:

if ( isset( $this->mapping['term'][ $key ] ) ) {
    $term_ids[ $taxonomy ][] = (int) $this->mapping['term'][ $key ];
} else {
    $meta[] = array( 'key' => '_wxr_import_term', 'value' => $term );
    $requires_remapping = true;
}

and terms in the post-format taxonomy seem to always end up in the else clause. However, it doesn't appear that anything is done with that $meta after the fact (e.g., in WXR_Importer::post_process_posts()).

I suspect that under certain circumstances the above could also result in other terms not being associated with imported posts, but those from the post-format taxonomy are the only ones I've seen it happen with in my testing.