Project

General

Profile

« Previous | Next » 

Revision 824b1e52

Added by Marcos M 6 months ago

Fix config access regressions during config upgrades

- 122_to_123: outbound rule saved to wrong path
- 130_to_131: operate on same types
- 136_to_137: handle potentially empty path
- 150_to_151: operate on same types
- 169_to_170: save the new wireless interface name

View differences:

src/etc/inc/upgrade_config.inc
3878 3878
				continue;
3879 3879
			}
3880 3880
		}
3881
		config_set_path('nat/rule', $onat_rule_config);
3881
		config_set_path('nat/outbound/rule', $onat_rule_config);
3882 3882
	}
3883 3883
}
3884 3884

  
......
4058 4058
			// dpinger uses milliseconds
4059 4059
			if (isset($gw['interval']) &&
4060 4060
				is_numeric($gw['interval'])) {
4061
				$gw['interval'] = $gw['interval'] * 1000;
4061
				$gw['interval'] = intval($gw['interval']) * 1000;
4062 4062
			}
4063 4063

  
4064 4064
			if (!empty($gw['interval'])) {
4065
				$effective_interval = $gw['interval'];
4065
				$effective_interval = intval($gw['interval']);
4066 4066
			} else {
4067 4067
				$effective_interval = $default_interval;
4068 4068
			}
4069 4069

  
4070 4070
			if (isset($gw['down']) &&
4071 4071
				is_numeric($gw['down'])) {
4072
				$gw['time_period'] = $gw['down'] * 1000;
4072
				$gw['time_period'] = intval($gw['down']) * 1000;
4073 4073
				unset($gw['down']);
4074 4074
			}
4075 4075

  
4076 4076
			if (!empty($gw['time_period'])) {
4077
				$effective_time_period = $gw['time_period'];
4077
				$effective_time_period = intval($gw['time_period']);
4078 4078
			} else {
4079 4079
				$effective_time_period = $default_time_period;
4080 4080
			}
......
4082 4082
			if (isset($gw['latencyhigh'])) {
4083 4083
				// Default loss_interval is 2000, but must be set
4084 4084
				// higher if latencyhigh is higher.
4085
				if ($gw['latencyhigh'] > $default_loss_interval) {
4086
					$gw['loss_interval'] = $gw['latencyhigh'];
4085
				if (intval($gw['latencyhigh']) > $default_loss_interval) {
4086
					$gw['loss_interval'] = intval($gw['latencyhigh']);
4087 4087
				}
4088 4088
			}
4089 4089

  
4090 4090
			if (!empty($gw['loss_interval'])) {
4091
				$effective_loss_interval = $gw['loss_interval'];
4091
				$effective_loss_interval = intval($gw['loss_interval']);
4092 4092
			} else {
4093 4093
				$effective_loss_interval = $default_loss_interval;
4094 4094
			}
......
4096 4096
			if (isset($gw['interval'])) {
4097 4097
				// Default alert_interval is 1000, but must be set
4098 4098
				// higher if interval is higher.
4099
				if ($gw['interval'] > $default_alert_interval) {
4100
					$gw['alert_interval'] = $gw['interval'];
4099
				if (intval($gw['interval']) > $default_alert_interval) {
4100
					$gw['alert_interval'] = intval($gw['interval']);
4101 4101
				}
4102 4102
			}
4103 4103

  
......
4223 4223
	$dhcpd_config = config_get_path('dhcpd');
4224 4224
	if (is_array($dhcpd_config)) {
4225 4225
		foreach ($dhcpd_config as &$dhcpd) {
4226
			if (!is_array($dhcpd['numberoptions']['item'])) {
4226
			if (!is_array($dhcpd) || !is_array(array_get_path($dhcpd, 'numberoptions/item'))) {
4227 4227
				continue;
4228 4228
			}
4229 4229

  
......
4237 4237
	$dhcpdv6_config = config_get_path('dhcpdv6');
4238 4238
	if (is_array($dhcpdv6_config)) {
4239 4239
		foreach ($dhcpdv6_config as &$dhcpdv6) {
4240
			if (!is_array($dhcpdv6['numberoptions']['item'])) {
4240
			if (!is_array($dhcpdv6) || !is_array(array_get_path($dhcpdv6, 'numberoptions/item'))) {
4241 4241
				continue;
4242 4242
			}
4243 4243

  
......
4730 4730
	if (is_array($gateways_config)) {
4731 4731
		foreach ($gateways_config as &$gw) {
4732 4732
			if (isset($gw['interval'])) {
4733
				$effective_interval = $gw['interval'];
4733
				$effective_interval = intval($gw['interval']);
4734 4734
			} else {
4735 4735
				$effective_interval = $default_interval;
4736 4736
			}
4737 4737

  
4738 4738
			if (isset($gw['alert_interval'])) {
4739
				$effective_alert_interval = $gw['alert_interval'];
4739
				$effective_alert_interval = intval($gw['alert_interval']);
4740 4740
			} else {
4741 4741
				$effective_alert_interval = $default_alert_interval;
4742 4742
			}
4743 4743

  
4744 4744
			if (isset($gw['loss_interval'])) {
4745
				$effective_loss_interval = $gw['loss_interval'];
4745
				$effective_loss_interval = intval($gw['loss_interval']);
4746 4746
			} else {
4747 4747
				$effective_loss_interval = $default_loss_interval;
4748 4748
			}
4749 4749

  
4750 4750
			if (isset($gw['time_period'])) {
4751
				$effective_time_period = $gw['time_period'];
4751
				$effective_time_period = intval($gw['time_period']);
4752 4752
			} else {
4753 4753
				$effective_time_period = $default_time_period;
4754 4754
			}
4755 4755

  
4756 4756
			if (isset($gw['latencyhigh'])) {
4757
				$effective_latencyhigh = $gw['latencyhigh'];
4757
				$effective_latencyhigh = intval($gw['latencyhigh']);
4758 4758
			} else {
4759 4759
				$effective_latencyhigh = $default_latencyhigh;
4760 4760
			}
......
5273 5273
 * Each wireless interface now needs to be a cloned instance, the card itself
5274 5274
 * Can no longer be assigned. https://redmine.pfsense.org/issues/6770 */
5275 5275
function upgrade_169_to_170() {
5276
	foreach (config_get_path('interfaces', []) as $friendly => & $iface) {
5276
	foreach (config_get_path('interfaces', []) as $friendly => $iface) {
5277 5277
		if (is_array($iface['wireless']) && !empty($iface['wireless']['mode'])) {
5278 5278
			/* This test can only be true for one instance per card, so it is safe. */
5279 5279
			if (stristr($iface['if'], '_wlan') === false) {
......
5286 5286
				/* Make sure this entry is placed in the list of wireless interface clones. */
5287 5287
				config_set_path('wireless/clone/', $wlan);
5288 5288
				/* The interface assignment must now be the cloned interface name. */
5289
				config_set_path("interfaces/{$friendly}/if", $wlan['cloneif']);
5289 5290
				$iface['if'] = $wlan['cloneif'];
5290 5291
			}
5291 5292
		}

Also available in: Unified diff