R3.3 needs fixes for PHP Notice: Undefined index: user_id
Posted: Tue Aug 28, 2012 11:55 am
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.
[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"]))