R3.3 needs fixes for PHP Notice: Undefined index: user_id

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nagiosadmin42
Posts: 96
Joined: Sat Feb 11, 2012 2:16 pm

R3.3 needs fixes for PHP Notice: Undefined index: user_id

Post by nagiosadmin42 »

I've noticed that the httpd error_log (/var/log/httpd/error_log) gets a lot of these messages:

[Tue Aug 28 09:35:27 2012] [error] [client ::1] PHP Notice: Undefined index: user_id in /usr/local/nagiosxi/html/includes/dbauth.inc.php on line 340
[Tue Aug 28 09:35:27 2012] [error] [client ::1] PHP Notice: Undefined index: user_id in /usr/local/nagiosxi/html/includes/utils-perms.inc.php on line 63
[Tue Aug 28 09:35:27 2012] [error] [client ::1] PHP Notice: Undefined index: user_id in /usr/local/nagiosxi/html/includes/utils-users.inc.php on line 273

I was able to fix two of the issues with the following code changes, however dbauth.inc.php is protected by SourceGuardian so I couldn't modify that file.

Code: Select all

# diff utils-perms.inc.php.ORIG utils-perms.inc.php
37c37,38
<       if($userid==0)
---
>       // make sure _SESSION entry is set before attempting to use it
>       if($userid==0 && isset($_SESSION["user_id"]))
63c64,67
<               $userid=$_SESSION["user_id"];
---
>               // make sure _SESSION entry is set before attempting to use it, otherwise generates entry in http error log:
>               // Undefined index: user_id in /usr/local/nagiosxi/html/includes/utils-perms.inc.php on line 63
>               if (isset($_SESSION["user_id"]))
>                       $userid=$_SESSION["user_id"];

# diff utils-users.inc.php.ORIG utils-users.inc.php
272c272,273
<       if($user_id==0)
---
>       // Fix for: Undefined index: user_id in /usr/local/nagiosxi/html/includes/utils-users.inc.php on line 273
>       if($user_id==0 && isset($_SESSION["user_id"]))
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: R3.3 needs fixes for PHP Notice: Undefined index: user_i

Post by scottwilkerson »

Thanks for the heads up.

These would only occur is someone's session had expired and as they were notices should be non-blocking.

That said, I have updated the files for the next release.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
nagiosadmin42
Posts: 96
Joined: Sat Feb 11, 2012 2:16 pm

Re: R3.3 needs fixes for PHP Notice: Undefined index: user_i

Post by nagiosadmin42 »

Yeah, it's definitely not a major issue, just nice to have the error log cleaned up when troubleshooting problems.

Thanks!

Alan
Locked