I have a complex taxonomy with many parent and child terms that recently started to cause an endless import loop when using this module. To identify the issue, I started looking into the "while ($firstRun || count($tidsLeft) > 0)" logic as that's the code that appeared to be looping endlessly, but as I was debugging I had a hunch that it was related to how that logic attempts to support child terms appearing in the loop before their parent terms. So, as a test, I updated importTaxonomies to sort taxonomies so that all parent terms appear before their child terms in the relevant arrays, and this seemed to have fixed the problem.
I will attach a patch for others looking for a quick fix for this issue, though I'm uncertain if there should be a corresponding update -- or alternate approach altogether -- relating to that "while" logic I mentioned.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | structure_sync.data_.yml | 21.18 KB | nwoodland |
| #2 | 3009375-taxonomy_with_parent_and_child_terms_can_lead_to_endless_import_loop-1.patch | 860 bytes | nwoodland |
Comments
Comment #2
nwoodland commentedHere's the patch we're using for this issue currently.
Comment #3
nwoodland commentedHere's a sample taxonomy export that led to this issue.
Comment #5
timkruijsen commentedPatch looks good to me, included in release 1.14. Thanks for your effort!
Comment #6
nwoodland commentedTim, glad to help! FYI that logic likely will only work 100% of the time for taxonomies that are one level deep, as it effectively ensures terms with no parent (parent = 0) appear first, but I assume this won't work the same for terms that are both parent and child terms, unless parent terms are consistently created before their children (so parents that are also children consistently point to a parent with a lower TID). Still, this simple sorting code shouldn't negatively impact anything and definitely corrects at least one known issue, so I hope this helps others!