util:legacy - ignore plugins_interfaces() errors in write_config() when called without sufficient imports (missing libraries in registered plugins).

Scripts like https://github.com/opnsense/core/blob/master/src/etc/rc.expireaccounts will die horribly at the moment when there's actual work to be done (although this example should likely be rmeoved for 25.1 anyway)
This commit is contained in:
Ad Schellevis 2024-12-11 15:46:23 +01:00
parent 988dbae92d
commit be8841d9af

View File

@ -197,7 +197,20 @@ function write_config($desc = '', $backup = true)
}
}
plugins_interfaces();
/**
* XXX: Temporary construction.
* When called via a legacy interface configure page, we might want to register new interfaces, but
* in cases we just want to save our changes (not related to interfaces), we risk raising errors for
* missing imports.
* Eventually relevant callers should call 'interface invoke registration', which is the same as
* mvc components use now (but can't be called here without side effects)
*/
try {
plugins_interfaces();
} catch (Throwable $e) {
null;
}
$cnf = OPNsense\Core\Config::getInstance();
$cnf->fromArray($config);