fix: Delete all port_id references #4684

This commit is contained in:
Søren Rosiak
2016-10-16 02:42:56 +03:00
committed by Neil Lathwood
parent a2f2ccfd2c
commit 71a6d6ed73

View File

@@ -140,15 +140,14 @@ function delete_port($int_id)
{
$interface = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE P.port_id = ? AND D.device_id = P.device_id", array($int_id));
$interface_tables = array('adjacencies', 'ipaddr', 'ip6adjacencies', 'ip6addr', 'mac_accounting', 'bill_ports', 'pseudowires', 'ports');
$interface_tables = array('ipv4_addresses', 'ipv4_mac', 'ipv6_addresses', 'juniAtmVp', 'mac_accounting', 'ospf_nbrs', 'ospf_ports', 'ports', 'ports_adsl', 'ports_perms', 'ports_statistics', 'ports_stp', 'ports_vlans', 'pseudowires');
foreach ($interface_tables as $table) {
dbDelete($table, "`port_id` = ?", array($int_id));
}
dbDelete('links', "`local_port_id` = ?", array($int_id));
dbDelete('links', "`remote_port_id` = ?", array($int_id));
dbDelete('bill_ports', "`port_id` = ?", array($int_id));
dbDelete('links', "`local_port_id` = ? OR `remote_port_id` = ?", array($int_id, $int_id));
dbDelete('ports_stack', "`port_id_low` = ? OR `port_id_high` = ?", array($int_id, $int_id));
unlink(get_port_rrdfile_path($interface['hostname'], $interface['port_id']));
}