Skip to content
Permalink
Browse files

Added check on nodes_hierarchy.id == nodes_hierarchy.parent_id with t…

…hrow
  • Loading branch information
fmancardi committed Jun 15, 2015
1 parent 6d80209 commit bb5d471425b85c2f180fd4060b2c2d452c1be958
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/functions/tree.class.php
@@ -480,8 +480,8 @@ function _get_path($node_id,&$node_list,$to_node_id=null,$format='full')

// look up the parent of this node
$sql = "/* $debugMsg */ " .
" SELECT id,name,parent_id,node_type_id,node_order FROM {$this->object_table} " .
" WHERE id = {$node_id} ";
" SELECT id,name,parent_id,node_type_id,node_order " .
" FROM {$this->object_table} WHERE id = " . intval($node_id);

$result = $this->db->exec_query($sql);
if( $this->db->num_rows($result) == 0 )
@@ -492,6 +492,12 @@ function _get_path($node_id,&$node_list,$to_node_id=null,$format='full')

while ( $row = $this->db->fetch_array($result) )
{
// check & abort
if($row['parent_id'] == $row['id'])
{
throw new Exception("id = parent_id = " . $row['id'], 1);
}

// only continue if this $node isn't the root node
// (that's the node with no parent)
if ($row['parent_id'] != '' && $row['id'] != $to_node_id)

0 comments on commit bb5d471

Please sign in to comment.
You can’t perform that action at this time.