• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

switch php errors on Netgate-SG-3100

L2/Switching/VLANs
vlan migration sg-3100 switch
2
5
1.0k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    adamw
    last edited by Nov 13, 2018, 12:12 PM

    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:

    1. 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

    2. 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

    1 Reply Last reply Reply Quote 0
    • J
      jimp Rebel Alliance Developer Netgate
      last edited by Nov 13, 2018, 1:44 PM

      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) {
      

      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

      Need help fast? Netgate Global Support!

      Do not Chat/PM for help!

      1 Reply Last reply Reply Quote 1
      • J
        jimp Rebel Alliance Developer Netgate
        last edited by Nov 13, 2018, 1:57 PM

        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";
        

        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply Reply Quote 1
        • A
          adamw
          last edited by Nov 13, 2018, 3:49 PM

          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?

          1 Reply Last reply Reply Quote 0
          • J
            jimp Rebel Alliance Developer Netgate
            last edited by Nov 13, 2018, 3:51 PM

            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.

            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

            Need help fast? Netgate Global Support!

            Do not Chat/PM for help!

            1 Reply Last reply Reply Quote 1
            5 out of 5
            • First post
              5/5
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.