From 32c20b8a680bceca268a8a22b056bd983d1f148f Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 15:38:54 +0100 Subject: [PATCH] Added removing of IP addresses before ports are deleted --- includes/functions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/functions.php b/includes/functions.php index 7258508973..18937bb537 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -248,6 +248,10 @@ function delete_device($id) return "No such host."; } + // Remove IPv4/IPv6 addresses before removing ports as they depend on port_id + dbQuery("DELETE `ipv4_addresses` FROM `ipv4_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv4_addresses`.`port_id` WHERE `device_id`=?",array($id)); + dbQuery("DELETE `ipv6_addresses` FROM `ipv6_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv6_addresses`.`port_id` WHERE `device_id`=?",array($id)); + foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $int_data) { $int_if = $int_data['ifDescr'];