Skip to content

Commit 293cbca

Browse files
fix: handle missing gateways in RoutingGatewayGroup::from_internal_ipprotocol() #603
1 parent aa6cd74 commit 293cbca

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/RoutingGatewayGroup.inc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,16 @@ class RoutingGatewayGroup extends Model {
6868
protected function from_internal_ipprotocol(): string {
6969
# Check the IP protocol of the gateways in this group
7070
foreach ($this->priorities->value as $priority) {
71-
$gw_obj = RoutingGateway::query(name: $priority['gateway'])->first();
71+
# Query for the gateway related to this priority
72+
$gw_q = RoutingGateway::query(name: $priority['gateway']);
73+
74+
# Skip this priority if the gateway does not exist. This can happen if the gateway is not in config.
75+
if (!$gw_q->exists()) {
76+
continue;
77+
}
78+
79+
# Check the IP protocol of the gateway
80+
$gw_obj = $gw_q->first();
7281
if ($gw_obj->ipprotocol->value === 'inet') {
7382
return 'inet';
7483
} elseif ($gw_obj->ipprotocol->value === 'inet6') {

0 commit comments

Comments
 (0)