diff options
author | Chris Buechler <cmb@pfsense.org> | 2016-04-22 00:40:41 -0500 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2016-04-22 00:40:41 -0500 |
commit | 1d616571820961c9a3d1590202737787d49b4ecd (patch) | |
tree | fa443d9facffab68858e179ff98d4ba2bf76cf3a | |
parent | c9d581660186a18dfad03ebe95d2031a26fbf7c5 (diff) | |
download | pfsense-1d616571820961c9a3d1590202737787d49b4ecd.zip pfsense-1d616571820961c9a3d1590202737787d49b4ecd.tar.gz |
Don't foreach unless it's an array. Ticket #6142
-rw-r--r-- | src/etc/inc/upgrade_config.inc | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/src/etc/inc/upgrade_config.inc b/src/etc/inc/upgrade_config.inc index b0e110f..2b15757 100644 --- a/src/etc/inc/upgrade_config.inc +++ b/src/etc/inc/upgrade_config.inc @@ -4845,50 +4845,52 @@ function upgrade_150_to_151() { $default_latencyhigh = 500; // Check advanced gateway parameter relationships in case they are incorrect - foreach ($config['gateways']['gateway_item'] as &$gw) { - if (isset($gw['interval'])) { - $effective_interval = $gw['interval']; - } else { - $effective_interval = $default_interval; - } + if (is_array($config['gateways']['gateway_item'])) { + foreach ($config['gateways']['gateway_item'] as &$gw) { + if (isset($gw['interval'])) { + $effective_interval = $gw['interval']; + } else { + $effective_interval = $default_interval; + } - if (isset($gw['alert_interval'])) { - $effective_alert_interval = $gw['alert_interval']; - } else { - $effective_alert_interval = $default_alert_interval; - } + if (isset($gw['alert_interval'])) { + $effective_alert_interval = $gw['alert_interval']; + } else { + $effective_alert_interval = $default_alert_interval; + } - if (isset($gw['loss_interval'])) { - $effective_loss_interval = $gw['loss_interval']; - } else { - $effective_loss_interval = $default_loss_interval; - } + if (isset($gw['loss_interval'])) { + $effective_loss_interval = $gw['loss_interval']; + } else { + $effective_loss_interval = $default_loss_interval; + } - if (isset($gw['time_period'])) { - $effective_time_period = $gw['time_period']; - } else { - $effective_time_period = $default_time_period; - } + if (isset($gw['time_period'])) { + $effective_time_period = $gw['time_period']; + } else { + $effective_time_period = $default_time_period; + } - if (isset($gw['latencyhigh'])) { - $effective_latencyhigh = $gw['latencyhigh']; - } else { - $effective_latencyhigh = $default_latencyhigh; - } + if (isset($gw['latencyhigh'])) { + $effective_latencyhigh = $gw['latencyhigh']; + } else { + $effective_latencyhigh = $default_latencyhigh; + } - // Loss interval has to be at least as big as high latency. - if ($effective_latencyhigh > $effective_loss_interval) { - $effective_loss_interval = $gw['loss_interval'] = $effective_latencyhigh; - } + // Loss interval has to be at least as big as high latency. + if ($effective_latencyhigh > $effective_loss_interval) { + $effective_loss_interval = $gw['loss_interval'] = $effective_latencyhigh; + } - // Alert interval has to be at least as big as probe interval. - if ($effective_interval > $effective_alert_interval) { - $gw['alert_interval'] = $effective_interval; - } + // Alert interval has to be at least as big as probe interval. + if ($effective_interval > $effective_alert_interval) { + $gw['alert_interval'] = $effective_interval; + } - // The time period for averaging has to be more than 2 probes plus the loss interval. - if ((($effective_interval * 2) + $effective_loss_interval) >= $effective_time_period) { - $gw['time_period'] = ($effective_interval * 2) + $effective_loss_interval + 1; + // The time period for averaging has to be more than 2 probes plus the loss interval. + if ((($effective_interval * 2) + $effective_loss_interval) >= $effective_time_period) { + $gw['time_period'] = ($effective_interval * 2) + $effective_loss_interval + 1; + } } } } |