diff options
author | Phil Davis <phil.davis@inf.org> | 2016-04-22 12:28:22 +0545 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2016-04-23 04:33:14 -0500 |
commit | a39e519bdd5e91b9a7d7f3c13a974bc7f25fee4e (patch) | |
tree | 605c9bbc2cf4558642174c8df764f03b194806ab | |
parent | ae5684656d0d9bebdbe42ab8134895d2055239d1 (diff) | |
download | pfsense-a39e519bdd5e91b9a7d7f3c13a974bc7f25fee4e.zip pfsense-a39e519bdd5e91b9a7d7f3c13a974bc7f25fee4e.tar.gz |
Don't foreach unless it's an array. Ticket #6142
Similar thing to https://github.com/pfsense/pfsense/commit/13dab3538fe8b6c1688142c89a017520ad0aaac6 should be done here in upgrade_130_to_131()
-rw-r--r-- | src/etc/inc/upgrade_config.inc | 118 |
1 files changed, 60 insertions, 58 deletions
diff --git a/src/etc/inc/upgrade_config.inc b/src/etc/inc/upgrade_config.inc index 8c7495f..2a52979 100644 --- a/src/etc/inc/upgrade_config.inc +++ b/src/etc/inc/upgrade_config.inc @@ -4167,74 +4167,76 @@ function upgrade_130_to_131() { return; } - foreach ($config['gateways']['gateway_item'] as &$gw) { - // dpinger uses milliseconds - if (isset($gw['interval']) && - is_numeric($gw['interval'])) { - $gw['interval'] = $gw['interval'] * 1000; - } + if (is_array($config['gateways']['gateway_item'])) { + foreach ($config['gateways']['gateway_item'] as &$gw) { + // dpinger uses milliseconds + if (isset($gw['interval']) && + is_numeric($gw['interval'])) { + $gw['interval'] = $gw['interval'] * 1000; + } - if (isset($gw['interval'])) { - $effective_interval = $gw['interval']; - } else { - $effective_interval = $default_interval; - } + if (isset($gw['interval'])) { + $effective_interval = $gw['interval']; + } else { + $effective_interval = $default_interval; + } - if (isset($gw['down']) && - is_numeric($gw['down'])) { - $gw['time_period'] = $gw['down'] * 1000; - unset($gw['down']); - } + if (isset($gw['down']) && + is_numeric($gw['down'])) { + $gw['time_period'] = $gw['down'] * 1000; + unset($gw['down']); + } - 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'])) { - // Default loss_interval is 2000, but must be set - // higher if latencyhigh is higher. - if ($gw['latencyhigh'] > $default_loss_interval) { - $gw['loss_interval'] = $gw['latencyhigh']; + if (isset($gw['latencyhigh'])) { + // Default loss_interval is 2000, but must be set + // higher if latencyhigh is higher. + if ($gw['latencyhigh'] > $default_loss_interval) { + $gw['loss_interval'] = $gw['latencyhigh']; + } } - } - 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['interval'])) { - // Default alert_interval is 1000, but must be set - // higher if interval is higher. - if ($gw['interval'] > $default_alert_interval) { - $gw['alert_interval'] = $gw['interval']; + if (isset($gw['interval'])) { + // Default alert_interval is 1000, but must be set + // higher if interval is higher. + if ($gw['interval'] > $default_alert_interval) { + $gw['alert_interval'] = $gw['interval']; + } } - } - if ((($effective_interval * 2) + $effective_loss_interval) >= $effective_time_period) { - $gw['time_period'] = ($effective_interval * 2) + $effective_loss_interval + 1; - } + if ((($effective_interval * 2) + $effective_loss_interval) >= $effective_time_period) { + $gw['time_period'] = ($effective_interval * 2) + $effective_loss_interval + 1; + } - if (isset($gw['avg_delay_samples'])) { - unset($gw['avg_delay_samples']); - } - if (isset($gw['avg_delay_samples_calculated'])) { - unset($gw['avg_delay_samples_calculated']); - } - if (isset($gw['avg_loss_samples'])) { - unset($gw['avg_loss_samples']); - } - if (isset($gw['avg_loss_samples_calculated'])) { - unset($gw['avg_loss_samples_calculated']); - } - if (isset($gw['avg_loss_delay_samples'])) { - unset($gw['avg_loss_delay_samples']); - } - if (isset($gw['avg_loss_delay_samples_calculated'])) { - unset($gw['avg_loss_delay_samples_calculated']); + if (isset($gw['avg_delay_samples'])) { + unset($gw['avg_delay_samples']); + } + if (isset($gw['avg_delay_samples_calculated'])) { + unset($gw['avg_delay_samples_calculated']); + } + if (isset($gw['avg_loss_samples'])) { + unset($gw['avg_loss_samples']); + } + if (isset($gw['avg_loss_samples_calculated'])) { + unset($gw['avg_loss_samples_calculated']); + } + if (isset($gw['avg_loss_delay_samples'])) { + unset($gw['avg_loss_delay_samples']); + } + if (isset($gw['avg_loss_delay_samples_calculated'])) { + unset($gw['avg_loss_delay_samples_calculated']); + } } } } |