From 19a82e150004864ced7813c93a236de49c971867 Mon Sep 17 00:00:00 2001 From: Mathieu Poussin <359877+kedare@users.noreply.github.com> Date: Mon, 10 Feb 2020 12:07:27 +0100 Subject: [PATCH] Fix inventory page hostname/sysname and default generate_device_link behaviour (#11114) * Fix inventory page hostname and default behaviour on generate_device_link * force test re-run * space * simplify Co-authored-by: PipoCanaja <38363551+PipoCanaja@users.noreply.github.com> --- includes/html/functions.inc.php | 6 ++---- includes/html/table/inventory.inc.php | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/includes/html/functions.inc.php b/includes/html/functions.inc.php index 70e0fbffb9..28c8d6c0e6 100644 --- a/includes/html/functions.inc.php +++ b/includes/html/functions.inc.php @@ -18,7 +18,8 @@ use LibreNMS\Config; * Compare $t with the value of $vars[$v], if that exists * @param string $v Name of the var to test * @param string $t Value to compare $vars[$v] to - * @return boolean true, if values are the same, false if $vars[$v] is unset or values differ + * @return boolean true, if values are the same, false if $vars[$v] + * is unset or values differ */ function var_eq($v, $t) { @@ -174,9 +175,6 @@ function generate_device_link($device, $text = null, $vars = array(), $start = 0 } $class = devclass($device); - if (!$text) { - $text = $device['hostname']; - } $text = format_hostname($device, $text); diff --git a/includes/html/table/inventory.inc.php b/includes/html/table/inventory.inc.php index 404eb23db3..4e337056cb 100644 --- a/includes/html/table/inventory.inc.php +++ b/includes/html/table/inventory.inc.php @@ -61,11 +61,11 @@ if ($rowCount != -1) { $sql .= " LIMIT $limit_low,$limit_high"; } -$sql = "SELECT `D`.`device_id` AS `device_id`, `D`.`hostname` AS `hostname`,`entPhysicalDescr` AS `description`, `entPhysicalName` AS `name`, `entPhysicalModelName` AS `model`, `entPhysicalSerialNum` AS `serial` $sql"; +$sql = "SELECT `D`.`device_id` AS `device_id`, `D`.`hostname` AS `hostname`, `D`.`sysName` AS `sysName`,`entPhysicalDescr` AS `description`, `entPhysicalName` AS `name`, `entPhysicalModelName` AS `model`, `entPhysicalSerialNum` AS `serial` $sql"; foreach (dbFetchRows($sql, $param) as $invent) { $response[] = array( - 'hostname' => generate_device_link($invent, shortHost($invent['hostname'])), + 'hostname' => generate_device_link($invent), 'description' => $invent['description'], 'name' => $invent['name'], 'model' => $invent['model'],