
Originally Posted by
Nitroedge
Thanks, worked perfectly and I can report the page is loading correctly now with all the new features and functionality.
I have been testing it and the only problem I have is I am getting the following error in the admin debug logs each time I view the report:
[16-Jul-2017 07:50:39 America/Detroit] PHP Warning: array_key_exists() expects parameter 2 to be array, null given in user_tracking.php on line 283
This error occurs whether I have show/hide spiders or show/hide filters on. It appears to occur each time the User Tracking report is loaded or refreshed.
I see why/how it is generated. When first going through the records, if $user_tracking hasn't been declared as an array() (which I thought it had, but I see that it wasn't) then when testing if a key is in the non-declared array an error like that could be expected. This is done by inserting a line before the while (!$whos_online->EOF related line that has:
Code:
$user_tracking = array();
Alternatively that if statement:
Code:
if ($user_filter_search == 'HideOnly' && array_key_exists('filterwordfound', $user_tracking[$whos_online->fields['session_id']])) {
Could be made false earlier by inserting
Code:
&& !empty($user_tracking)
in the if statement after 'HideOnly'. Logic analysis will stop as soon as a false condition is encountered as evaluated from left to right following an order of precedence.
I'm thinking the first solution of establishing the variable as an array is the better solution (1 assignment to put the variable in a known and needed state of being an array and it does not increase processing for each loop by basically evaluating if $user_tracking is an array on each loop), but I need to look at the code that is after the while loop to see if the code that follows would behave incorrectly in the condition that there were no records to review/retrieve.
And yup, just after the closing curly parenthesis of the while loop the check is if $user_tracking is an array.
this same check is used later in the code as well. So more does need to be changed than just adding the one line to prevent generating that warning which I guess I'm surprised has been supressed in the environment tested. Here at the is_array($user_tracking) == true would want to instead use the !empty($user_tracking) check instead when using the previous $user_tracking = array(); statement.
Alright patch coming up... :)
Bookmarks