From b555edee5e443fa28bda46430432847f3b28f987 Mon Sep 17 00:00:00 2001 From: SourceDoctor Date: Sun, 8 Dec 2019 22:18:52 +0100 Subject: [PATCH] Remove redundant discovery call (#10875) --- includes/html/forms/rediscover-device.inc.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/includes/html/forms/rediscover-device.inc.php b/includes/html/forms/rediscover-device.inc.php index 82ec7f40fe..2733d6e83e 100644 --- a/includes/html/forms/rediscover-device.inc.php +++ b/includes/html/forms/rediscover-device.inc.php @@ -21,20 +21,18 @@ if (!Auth::user()->hasGlobalAdmin()) { exit; } -// FIXME: Make this part of the API instead of a standalone function if (isset($_POST['device_id'])) { if (!is_numeric($_POST['device_id'])) { $status = 'error'; $message = 'Invalid device id ' . $_POST['device_id']; } else { - $update = dbUpdate(array('last_discovered' => array('NULL')), 'devices', '`device_id` = ?', array($_POST['device_id'])); - if (!empty($update) || $update == '0') { - $status = 'ok'; - $message = 'Device ' . $_POST['device_id'] . ' will be rediscovered'; + $result = device_discovery_trigger($_POST['device_id']); + if (!empty($result['status']) || $result['status'] == '0') { + $status = 'ok'; } else { - $status = 'error'; - $message = 'Error rediscovering device ' . $_POST['device_id']; + $status = 'error'; } + $message = $result['message']; } } elseif (isset($_POST['device_group_id'])) { if (!is_numeric($_POST['device_group_id'])) { @@ -44,7 +42,8 @@ if (isset($_POST['device_id'])) { $device_ids = dbFetchColumn("SELECT `device_id` FROM `device_group_device` WHERE `device_group_id`=" . $_POST['device_group_id']); $update = 0; foreach ($device_ids as $device_id) { - $update += dbUpdate(array('last_discovered' => array('NULL')), 'devices', '`device_id` = ?', array($device_id)); + $result = device_discovery_trigger($device_id); + $update += $result['status']; } if (!empty($update) || $update == '0') {