diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml index 3e4ac83737..378926025b 100644 --- a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml +++ b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml @@ -1,5 +1,7 @@ - //OPNsense/Firewall/FilterRule + //OPNsense/Firewall/Filter + 1.0.0 + MFP OPNsense firewall filter rules diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Migrations/MFP1_0_0.php b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Migrations/MFP1_0_0.php new file mode 100644 index 0000000000..d6118f1e51 --- /dev/null +++ b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Migrations/MFP1_0_0.php @@ -0,0 +1,57 @@ +Firewall->FilterRule ---> OPNsense->Firewall->Filter + $cfgObj = Config::getInstance()->object(); + if (!empty($cfgObj->OPNsense) && !empty($cfgObj->OPNsense->Firewall) + && !empty($cfgObj->OPNsense->Firewall->FilterRule)) { + // model migration created a new, empty rules section + if (empty($cfgObj->OPNsense->Firewall->Filter->rules)) { + unset($cfgObj->OPNsense->Firewall->Filter->rules); + $targetdom = dom_import_simplexml($cfgObj->OPNsense->Firewall->Filter); + foreach ($cfgObj->OPNsense->Firewall->FilterRule->children() as $child) { + $sourcedom = dom_import_simplexml($child); + $targetdom->appendChild($sourcedom); + } + unset($cfgObj->OPNsense->Firewall->FilterRule); + Config::getInstance()->save(); + } + } + } +} \ No newline at end of file