From b471626fdb8d95252b33ffe8b4037c75eb7012ca Mon Sep 17 00:00:00 2001 From: Nick Liu Date: Fri, 22 Jun 2018 14:00:13 -0500 Subject: [PATCH] Fixed missing tree nodes for some tree structures There were two cases that led to missing tree nodes: * If one node at the same depth as another node had a higher primary key ID but showed up in the rows before, the lower primary key ID node will go missing. * If an unmatching row for the current node in moveRowsToTreeNodes appeared between a matching row, the matching row would never be reached and would not be added to the tree. --- e107_handlers/model_class.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index e7157ac6d..346f325ac 100755 --- a/e107_handlers/model_class.php +++ b/e107_handlers/model_class.php @@ -3456,10 +3456,7 @@ class e_tree_model extends e_front_model $rowParentID = (int) $row[$sort_parent]; // Note: This optimization only works if the SQL query executed was ordered by the sort parent. - if($nodeID !== $rowParentID) - { - break; - } + if($rowParentID > $nodeID) break; $node['_children'][] = &$row; unset($rows[$key]); @@ -3620,7 +3617,7 @@ class e_tree_model extends e_front_model return ""; }, $db_query) // Optimization goes with e_tree_model::moveRowsToTreeNodes() - . " ORDER BY " . $this->getParam('sort_parent'); + . " ORDER BY " . $this->getParam('sort_parent') . "," . $this->getParam('primary_field'); $this->setParam('db_query', $db_query); }