1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 03:40:37 +02:00

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.
This commit is contained in:
Nick Liu
2018-06-22 14:00:13 -05:00
parent 32b844dad3
commit b471626fdb

View File

@@ -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);
}