Project

General

Profile

« Previous | Next » 

Revision 29bed760

Added by Reid Linnemann almost 3 years ago

Use config_get_path() for friendly ifnames and vlan configs

These elements may not exist in the config depending on the user config and
available ifaces, causing errors in php 8 when attempting to do element access
on a string or nil value.

View differences:

src/etc/inc/config.console.inc
79 79
		$ifsmallist = " ";
80 80
		foreach ($iflist as $iface => $ifa) {
81 81
			$friendly = convert_real_interface_to_friendly_interface_name($iface);
82
			$ifstatus = get_interface_addresses($config['interfaces'][$friendly]['if']);
82
			$ifstatus = get_interface_addresses(config_get_path("interfaces{$friendly}/if", ""));
83 83
			if (is_array($ifstatus) && $ifstatus['linkstateup'])
84 84
				$status = "  (up)";
85 85
			else
......
105 105
		vlan_setup();
106 106
	}
107 107

  
108
	if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
109

  
108
	$vlans = config_get_path('vlans/vlan', []);
109
	if (is_array($vlans) && count($vlans)) {
110 110
		echo "\n\n" . gettext("VLAN interfaces:") . "\n\n";
111
		foreach ($config['vlans']['vlan'] as $vlan) {
112

  
111
		foreach ($vlans as $vlan) {
113 112
			echo sprintf("% -16s%s\n", vlan_interface($vlan),
114 113
				"VLAN tag {$vlan['tag']}, parent interface {$vlan['if']}");
115

  
116 114
			$iflist[vlan_interface($vlan)] = array();
117 115
			$ifsmallist = $ifsmallist . vlan_interface($vlan) . " ";
118 116
		}
......
394 392
		}
395 393

  
396 394
		echo gettext(" done!") . "\n";
397

  
398 395
		return (0);
399 396
	}
397
	return (1);
400 398
}
401 399

  
402 400
function autodetect_interface($ifname, $fp) {

Also available in: Unified diff