diff --git a/includes/common.php b/includes/common.php index 60b8ef292..7f6fcee7b 100644 --- a/includes/common.php +++ b/includes/common.php @@ -300,7 +300,15 @@ function getidbyname($hostname) { global $cache; - return $cache['devices']['hostname'][$hostname]; + if ($cache['devices']['hostname'][$hostname]) + { + $id = $cache['devices']['hostname'][$hostname]; + } else + { + $id = dbFetchCell("SELECT `device_id` FROM `devices` WHERE `hostname` = ?", array($domain)); + } + + return $id; } function gethostosbyid($id)