Skip to content

Improved hierarchical term handling#129

Open
dcavins wants to merge 4 commits into
humanmade:masterfrom
dcavins:term-parent-handling
Open

Improved hierarchical term handling#129
dcavins wants to merge 4 commits into
humanmade:masterfrom
dcavins:term-parent-handling

Conversation

@dcavins
Copy link
Copy Markdown
Contributor

@dcavins dcavins commented Jun 22, 2017

This PR adds handling for hierarchical terms:
• Make sure that newly added terms are added to the $exists array and found by WXR_Importer::term_exists().
• Basic term parent setting when the parent exists before the child term is created.
• Deferred term parent setting when the child term is encountered before the parent term exists.

Please let me know if you have any questions.

This is a great project, thanks for taking it on!

dcavins added 3 commits June 22, 2017 14:52
When terms were inserted, they were being added to the `$mapping` cache array, but not to the `$exists` cache array. This causes `WXR::term_exists()` to fail to find any terms added so far in this import.
As each term is processed, set the term parent if the parent can be found.
If the WXR reader encounters a child term before its parent term, it cannot set the child/parent relationship at the time the child term is created. In this case, we save the parent term slug as meta on the child term. Then, after all terms are inserted, loop through and update the parent/child relationships as needed .
Copy link
Copy Markdown

@pbiron pbiron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR does appear to correct the problem I reported in #121.

It is also better than the fix that I had prepared for that issue because it implements the $this->remapping_required['term'] processing which I hadn't done (mine required the parent term to have occurred prior to the child term in the export file). I'm not 100% sure that the new WXR_Importer::post_process_terms() method is correct but it works on all the tests that I've run. Someone with a better grip on how the rest of the remapping code works should verify this before merge.

Passing term IDs to WP as strings results in WP
making new terms. For existing terms, always cast
the ID as an integer to avoid this issue (and to
ensure a match).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants