Fix some ErrorExceptions (#14241)

* Fix some ErrorExceptions

* Use Config::get default value

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Jellyfrog
2022-08-25 10:03:06 +02:00
committed by GitHub
parent a0b8b09f97
commit 835eac1233
5 changed files with 8 additions and 6 deletions

View File

@@ -378,7 +378,9 @@ if ($options['f'] === 'mac_oui') {
if ($options['f'] === 'refresh_os_cache') {
echo 'Clearing OS cache' . PHP_EOL;
unlink(Config::get('install_dir') . '/cache/os_defs.cache');
if (is_file(Config::get('install_dir') . '/cache/os_defs.cache')) {
unlink(Config::get('install_dir') . '/cache/os_defs.cache');
}
}
if ($options['f'] === 'recalculate_device_dependencies') {

View File

@@ -127,7 +127,7 @@ if (Config::get('enable_bgp')) {
}
}
foreach ($j_afisafi[$j_peerIndexes[$peer['ip']]] as $afisafi) {
foreach ($j_afisafi[$j_peerIndexes[$peer['ip']]] ?? [] as $afisafi) {
[$afi,$safi] = explode('.', $afisafi);
$afi = $afis[$afi];
$safi = $safis[$safi];

View File

@@ -1268,7 +1268,7 @@ function cache_peeringdb()
$json_data = $get->body();
$data = json_decode($json_data);
$ixs = $data->{'data'}[0]->{'netixlan_set'};
foreach ($ixs as $ix) {
foreach ($ixs ?? [] as $ix) {
$ixid = $ix->{'ix_id'};
$tmp_ix = dbFetchRow('SELECT * FROM `pdb_ix` WHERE `ix_id` = ? AND asn = ?', [$ixid, $asn]);
if ($tmp_ix) {

View File

@@ -74,7 +74,7 @@ if ($_GET['previous']) {
$rrd_options .= " COMMENT:'\\n'";
foreach ($rrd_list as $rrd) {
foreach ($rrd_list ?? [] as $rrd) {
if (! Config::get("graph_colours.$colours_in.$iter") || ! Config::get("graph_colours.$colours_out.$iter")) {
$iter = 0;
}

View File

@@ -21,7 +21,7 @@ if (count($drives)) {
$skipdrive = 0;
if ($device['os'] == 'junos') {
foreach (\LibreNMS\Config::get('ignore_junos_os_drives') as $jdrive) {
foreach (\LibreNMS\Config::get('ignore_junos_os_drives', []) as $jdrive) {
if (preg_match($jdrive, $drive['storage_descr'])) {
$skipdrive = 1;
}
@@ -31,7 +31,7 @@ if (count($drives)) {
}
if ($device['os'] == 'freebsd') {
foreach (\LibreNMS\Config::get('ignore_bsd_os_drives') as $jdrive) {
foreach (\LibreNMS\Config::get('ignore_bsd_os_drives', []) as $jdrive) {
if (preg_match($jdrive, $drive['storage_descr'])) {
$skipdrive = 1;
}