switch php errors on Netgate-SG-3100
-
Hi all.
It's a brand new box running 2.4.4.
I'm working with config exported from 2.3.4 on an old 32-bit 3-port ALIX device and accessing via WAN as I want to reconfigure LAN ports.My errors:
-
Crash report details
PHP Errors:
[08-Nov-2018 15:26:40 Etc/UTC] PHP Fatal error: Uncaught Error: Cannot unset string offsets in /etc/inc/switch.inc:479
Stack trace:
#0 /etc/inc/switch.inc(513): r1_switch_initial_setup()
#1 /etc/inc/switch.inc(636): default_switch_configure()
#2 /etc/rc.bootup(199): switches_configure()
#3 {main}
thrown in /etc/inc/switch.inc on line 479 -
Also when clicking opening Interfacies -> Switches -> VLANs
/switch_vlans.php
Fatal error: Uncaught Error: Cannot create references to/from string offsets in /usr/local/www/switch_vlans.php:36 Stack trace: #0 {main} thrown in /usr/local/www/switch_vlans.php on line 36 PHP ERROR: Type: 1, File: /usr/local/www/switch_vlans.php, Line: 36, Message: Uncaught Error: Cannot create references to/from string offsets in /usr/local/www/switch_vlans.php:36 Stack trace: #0 {main} thrown
Please advise.
Thanks,
Adam -
-
Looks like somehow the switch config is empty (rather than undefined) which is leading to a PHP error.
Try this patch using the system patches package:
diff --git a/src/usr/local/www/switch_vlans.php b/src/usr/local/www/switch_vlans.php index fa99073001..6a6ccaf05c 100644 --- a/src/usr/local/www/switch_vlans.php +++ b/src/usr/local/www/switch_vlans.php @@ -29,10 +29,7 @@ require_once("guiconfig.inc"); require_once("switch.inc"); -if (!is_array($config['switches']['switch'])) { - $config['switches']['switch'] = array(); -} - +init_config_arr(array('switches', 'switch')); $a_switches = &$config['switches']['switch']; $pgtitle = array(gettext("Interfaces"), gettext("Switch"), gettext("VLANs")); diff --git a/src/usr/local/www/switch_vlans_edit.php b/src/usr/local/www/switch_vlans_edit.php index 755d5ade62..402756a3d9 100644 --- a/src/usr/local/www/switch_vlans_edit.php +++ b/src/usr/local/www/switch_vlans_edit.php @@ -29,14 +29,7 @@ require_once("guiconfig.inc"); require_once("switch.inc"); -if (!is_array($config['switches'])) { - $config['switches'] = array(); -} - -if (!is_array($config['switches']['switch'])) { - $config['switches']['switch'] = array(); -} - +init_config_arr(array('switches', 'switch')); $a_switches = &$config['switches']['switch']; function find_vgroup_id($vgroups = NULL, $vlangroup = -1) {
-
Forgot one. That above will fix the GUI page, the error from
switch.inc
we fixed last month in the repo with this:diff --git a/src/etc/inc/switch.inc b/src/etc/inc/switch.inc index f1773e14c0..d557a8d09b 100644 --- a/src/etc/inc/switch.inc +++ b/src/etc/inc/switch.inc @@ -351,12 +351,8 @@ function switch_set_vlan_mode($swdev = NULL, $vlanmode = NULL) { function sg1100_switch_initial_setup() { global $config; - if (!isset($config['switches']['switch']) || !is_array($config['switches']['switch'])) { - unset($config['switches']['switch']); - $config['switches']['switch'] = array(); - } - /* Default settings for the SG-1100 switch. */ + init_config_arr(array('switches', 'switch')); $switches = &$config['switches']['switch']; $switch = array(); $switch['device'] = "/dev/etherswitch0"; @@ -412,12 +408,8 @@ function sg1100_switch_initial_setup() { function plccb_switch_initial_setup() { global $config; - if (!isset($config['switches']['switch']) || !is_array($config['switches']['switch'])) { - unset($config['switches']['switch']); - $config['switches']['switch'] = array(); - } - /* Default settings for the XG-7100 switch. */ + init_config_arr(array('switches', 'switch')); $switches = &$config['switches']['switch']; $switch = array(); $switch['device'] = "/dev/etherswitch0"; @@ -475,12 +467,8 @@ function plccb_switch_initial_setup() { function r1_switch_initial_setup() { global $config; - if (!isset($config['switches']['switch']) || !is_array($config['switches']['switch'])) { - unset($config['switches']['switch']); - $config['switches']['switch'] = array(); - } - /* Default settings for the SG-3100 switch. */ + init_config_arr(array('switches', 'switch')); $switches = &$config['switches']['switch']; $switch = array(); $switch['device'] = "/dev/etherswitch0";
-
Thank you Jimp.
I've made all edits by hand as it was easier than connecting the device to the internet.
/switch_vlans.php page is not showing errors any more
I'm assuming official future updates will not fail because of these hacks? -
Correct, the patches above are copies of the changes made in the repository that will be used to build pfSense 2.4.4-p1. So not "hacks" exactly.
If it's all working for you now then there shouldn't be anything to worry about. When you upgrade to 2.4.4-p1 the manually edited files will be replaced with the copies from the new release, which already contain these changes.