Improved hierarchical term handling#129
Open
dcavins wants to merge 4 commits into
Open
Conversation
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 .
pbiron
reviewed
Jun 24, 2017
pbiron
left a comment
There was a problem hiding this comment.
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).
90ddd98 to
a577e6a
Compare
30 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds handling for hierarchical terms:
• Make sure that newly added terms are added to the
$existsarray and found byWXR_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!