Page 1 of 1

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

Posted: Tue Aug 28, 2012 11:55 am
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"]))

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

Posted: Tue Aug 28, 2012 12:42 pm
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.

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

Posted: Tue Aug 28, 2012 1:00 pm
by nagiosadmin42
Yeah, it's definitely not a major issue, just nice to have the error log cleaned up when troubleshooting problems.

Thanks!

Alan