summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornwoodland2018-10-26 14:19:43 (GMT)
committerTim Kruijsen2018-10-26 14:19:43 (GMT)
commit3d54914ce74fa312d786e7ae08e39396a365a7cd (patch)
tree8bc72a464895ec123d33c268bfcc3ddfa24c31db
parent3a60eb576bcc3c6f940fb4923ee4689d53bfd289 (diff)
Issue #3009375 by nwoodland: Taxonomy with parent and child terms can lead to endless import loopHEAD8.x-1.148.x-1.x
-rwxr-xr-xsrc/Controller/TaxonomiesController.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Controller/TaxonomiesController.php b/src/Controller/TaxonomiesController.php
index 1831025..4986ef1 100755
--- a/src/Controller/TaxonomiesController.php
+++ b/src/Controller/TaxonomiesController.php
@@ -151,6 +151,16 @@ class TaxonomiesController extends ControllerBase {
$taxonomies = $taxonomiesConfig;
}
+ // Sorts taxonomies so that all parent terms come before -- and therefore
+ // are created before -- their respective child terms
+ foreach ($taxonomies as $taxonomy => $terms) {
+ $parents = [];
+ foreach ($terms as $key => $term_data) {
+ $parents[$key] = $term_data['parent'];
+ }
+ array_multisort($parents, SORT_ASC, $taxonomies[$taxonomy]);
+ }
+
if (array_key_exists('drush', $form) && $form['drush'] === TRUE) {
$context = [];
$context['drush'] = TRUE;