OPNsense Forum

Archive => 24.1, 24.4 Legacy Series => Topic started by: Rschell on January 19, 2024, 10:04:11 PM

Title: Number of Undefined Variables and PHP errors
Post by: Rschell on January 19, 2024, 10:04:11 PM
I have been collecting a number of undefined variables in the following files:

             - $pdlen undefined at 498 and 501
             - $gps_ok undefined at 250
             - $_REQUEST['updateme'] is undefined at 36
             - $gps_ok undefined at 148

--- a/src/www/services_dhcpv6.php
+++ b/src/www/services_dhcpv6.php
@@ -70,6 +70,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$ifcfgip = $config['interfaces'][$if]['ipaddrv6'];
$ifcfgsn = $config['interfaces'][$if]['subnetv6'];

+$pdlen = -1;
if (isset($config['interfaces'][$if]['dhcpd6track6allowoverride'])) {
     list ($ifcfgip,, $ifcfgsn) = interfaces_primary_address6($if);
     $pdlen = calculate_ipv6_delegation_length($config['interfaces'][$if]['track6-interface']) - 1;

--- a/src/www/status_ntpd.php
+++ b/src/www/status_ntpd.php
@@ -31,6 +31,7 @@
require_once("guiconfig.inc");
require_once("interfaces.inc");

+$gps_ok = False;
if (!isset($config['ntpd']['noquery'])) {
     exec("/usr/local/sbin/ntpq -pnw | /usr/bin/tail +3", $ntpq_output);
     $ntpq_servers = array();

--- a/src/www/widgets/widgets/ntp_status.widget.php
+++ b/src/www/widgets/widgets/ntp_status.widget.php
@@ -33,7 +33,8 @@
require_once("guiconfig.inc");
require_once("widgets/include/ntp_status.inc");

-if ($_REQUEST['updateme']) {
+$gps_ok = False;
+if (isset($_REQUEST['updateme'])) {
//this block displays only on ajax refresh
     exec("/usr/local/sbin/ntpq -pn | /usr/bin/tail +3", $ntpq_output);
     $ntpq_counter = 0;


Noticed on my i7 12 core appliance, that the system temperatures were a bit off.
Each core pair 0:1, 2:3, etc. are displaying the same temp.  Also, cores 10, 11, and
12 followed core 1. So the sorting of the cores were not recognizing a numeric order.

My changes to fix the temperature display are:
--- a/src/opnsense/scripts/system/temperature.sh
+++ b/src/opnsense/scripts/system/temperature.sh
@@ -44,8 +44,6 @@ else
        # The grep is opportunistic, but at least we only grep the
        # variable names and not their content at the same time and
        # as long as we can find something that matches our search.
-       SYSCTLS=$(sysctl -aN | grep temperature)
-       if [ -n "${SYSCTLS}" ]; then
-               sysctl -e ${SYSCTLS} | sort
-       fi
+       sysctl -e dev.cpu | grep temperature | sort -t. -k3n
+       sysctl -e hw. | grep temperature | sort -t. -k4n
  fi

--- a/src/www/widgets/api/plugins/temperature.inc
+++ b/src/www/widgets/api/plugins/temperature.inc
@@ -46,9 +46,5 @@ function temperature_api()
         }
     }

-    usort($result, function ($item1, $item2) {
-        return strcmp(strtolower($item1['device']), strtolower($item2['device']                                                  ));
-    });
-
     return $result;
}


On my motherboard, the hardware zone 0 temp is always a constant value.  So in my instance
I have dropped the second sysctl query and just rely on the first sysctl dev.cpu query.
Title: Re: Number of Undefined Variables and PHP errors
Post by: Rschell on January 20, 2024, 05:53:20 PM
Here is another set of PHP warnings for each interface:

PHP Warning:  Undefined array key 0 in /usr/local/www/interfaces.php on line 479
PHP Warning:  Trying to access array offset on value of type null in /usr/local/www/interfaces.php on line 479
PHP Warning:  Undefined array key 0 in /usr/local/www/interfaces.php on line 489
PHP Warning:  Trying to access array offset on value of type null in /usr/local/www/interfaces.php on line 489
PHP Warning:  Undefined array key 0 in /usr/local/www/interfaces.php on line 490
PHP Warning:  Trying to access array offset on value of type null in /usr/local/www/interfaces.php on line 490
PHP Warning:  Undefined array key 0 in /usr/local/www/interfaces.php on line 491
PHP Warning:  Trying to access array offset on value of type null in /usr/local/www/interfaces.php on line 491
PHP Warning:  Undefined array key "ipaddrv6" in /usr/local/www/interfaces.php on line 2939
PHP Warning:  Undefined array key 0 in /usr/local/www/interfaces.php on line 3585
PHP Warning:  Trying to access array offset on value of type null in /usr/local/www/interfaces.php on line 3585


I currently don't have a solution to squash these Warnings.
Title: Re: Number of Undefined Variables and PHP errors
Post by: franco on January 31, 2024, 07:18:21 PM
This is normal for the decvelopment version as it has increased verbosity. We fix these as we work through the pages. Mind you all the static *.php files are going away anyway so we don't want to fix all there is. PHP has become quite chatty about how strict it's going to be. ;)


Cheers,
Franco