From dc94c78015ae4d52ba166708f1be6b77c3aeea31 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Tue, 17 Oct 2023 09:11:17 +0200 Subject: [PATCH] Gateways: Single - as part of the migration strategy we moved most of the boilerplate in our master branch, this just has the side affect of storing default (unchanged) values in system_gateways_edit.php. This commit aims to prevent these entries from being stored to offer a smoother migration to MVC later. --- src/www/system_gateways_edit.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/www/system_gateways_edit.php b/src/www/system_gateways_edit.php index 38e0c4d2e..985b04997 100644 --- a/src/www/system_gateways_edit.php +++ b/src/www/system_gateways_edit.php @@ -35,6 +35,7 @@ $gateways = new \OPNsense\Routing\Gateways(); $a_gateways = array_values($gateways->gatewaysIndexedByName(true, false, true)); $dpinger_default = $gateways->getDpingerDefaults(); + // form processing if ($_SERVER['REQUEST_METHOD'] === 'POST') { $pconfig = $_POST; @@ -334,6 +335,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif (isset($gateway['fargw'])) { unset($gateway['fargw']); } + /* XXX: temporary solution to prevent default values being stored when unchanged */ + foreach ($dpinger_default as $key => $value) { + if (isset($gateway[$key]) && $gateway[$key] == $value) { + unset($gateway[$key]); + } + } /* when saving the manual gateway we use the attribute which has the corresponding id */ if (isset($realid)) {