diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Routing/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Routing/Api/SettingsController.php index 41ff210ea58..74a73103187 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Routing/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Routing/Api/SettingsController.php @@ -205,12 +205,14 @@ public function delGatewayAction($uuid) } $groups = []; - foreach ($cfg->gateways->children() as $tag => $gw_group) { - if ($tag == 'gateway_group' && !empty($gw_group)) { - foreach ($gw_group->item as $item) { - $name = explode("|", (string)$item); - if ($name[0] == $gateway->name) { - $groups[] = (string)$gw_group->name; + if ($cfg->gateways->count() > 0) { + foreach ($cfg->gateways->children() as $tag => $gw_group) { + if ($tag == 'gateway_group' && !empty($gw_group)) { + foreach ($gw_group->item as $item) { + $name = explode("|", (string)$item); + if ($name[0] == $gateway->name) { + $groups[] = (string)$gw_group->name; + } } } }