Describe the bug
For my company we are automatically generating a geographic tree with more than 500 sites. Hosts will in general only be assigned to a site. Using that method the tree search will never return a hit for a host that belongs to specific site, because there is no record existing in graph_tree_items referring its individual host_id.
To Reproduce
Create some leaf sites, assign those to the Cacti tree or a tree branch and finally assign some hosts to those new test site records.
Go to the tree view and enter the first characters of one of those hosts.
Expected behavior
Hosts will be found, tree will be opened down to host level, including leaf site branches.
Reality
No hits. Cacti returns nothing.
Solution
Better solutions may exist, but the easiest way is to take the host table in function "get_matching_nodes()" two times (with a RIGHT JOIN) into account as follows:
$matching = db_fetch_assoc_prepared("SELECT gti.parent, gti.graph_tree_id
FROM graph_tree_items AS gti
LEFT JOIN host AS h
ON h.id=gti.host_id
RIGHT JOIN host AS h2
ON h2.site_id=gti.site_id
LEFT JOIN graph_templates_graph AS gtg
ON gtg.local_graph_id=gti.local_graph_id AND gtg.local_graph_id>0
WHERE gtg.title_cache LIKE ?
OR h.description LIKE ?
OR h.hostname LIKE ?
OR h2.description LIKE ?
OR h2.hostname LIKE ?
OR gti.title LIKE ?",
array($filter, $filter, $filter, $filter, $filter, $filter));
Screenshot
Patch in place

Version
Describe the bug
For my company we are automatically generating a geographic tree with more than 500 sites. Hosts will in general only be assigned to a site. Using that method the tree search will never return a hit for a host that belongs to specific site, because there is no record existing in graph_tree_items referring its individual host_id.
To Reproduce
Create some leaf sites, assign those to the Cacti tree or a tree branch and finally assign some hosts to those new test site records.
Go to the tree view and enter the first characters of one of those hosts.
Expected behavior
Hosts will be found, tree will be opened down to host level, including leaf site branches.
Reality
No hits. Cacti returns nothing.
Solution
Better solutions may exist, but the easiest way is to take the host table in function "get_matching_nodes()" two times (with a RIGHT JOIN) into account as follows:
Screenshot
Patch in place
Version