summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Buechler <cmb@pfsense.org>2016-04-22 00:40:41 -0500
committerChris Buechler <cmb@pfsense.org>2016-04-22 00:41:23 -0500
commit13dab3538fe8b6c1688142c89a017520ad0aaac6 (patch)
tree60cad98c96f37b2aa235a61e8a78e210d8300ec5 /src
parent8175a2a8d9ed2041d1adaa0b8363497de663b7c2 (diff)
downloadpfsense-13dab3538fe8b6c1688142c89a017520ad0aaac6.zip
pfsense-13dab3538fe8b6c1688142c89a017520ad0aaac6.tar.gz
Don't foreach unless it's an array. Ticket #6142
Diffstat (limited to 'src')
-rw-r--r--src/etc/inc/upgrade_config.inc76
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;
+ }
}
}
}
OpenPOWER on IntegriCloud