-
Notifications
You must be signed in to change notification settings - Fork 267
Description
Description
The error log produces these entries:
Sources/Logging.php (Line 567)
The database value you're trying to insert does not exist: id_member
Function: logActions
Sources/Logging.php (Line 546)
2: Trying to access array offset on value of type null
This one took me a bit to walk backwards through the data. So I will walk through the important pieces.
This is coming from a task, specifically GroupAct-Notify.php
In that code this is triggered
addMembersToGroup($row['id_member'], $row['id_group'], $row['hidden'] == 2 ? 'only_additional' : 'auto', true);
Which at the end of that logic the logging is called:
require_once($sourcedir . '/Logging.php');
foreach ($members as $member)
logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin');
The important piece is the array of data.
Which the logging function takes:
function logAction($action, array $extra = array(), $log_type = 'moderate')
{
return logActions(array(array(
'action' => $action,
'log_type' => $log_type,
'extra' => $extra,
)));
}
Which finally we end up with this:
if (isset($log['extra']['member_affected']))
$memID = $log['extra']['member_affected'];
else
$memID = $user_info['id'];
The problem is that $memID is null because it tried to access $user_info['id'], which isn't properly defined since we don't load the user up during cron actions. Thus a error is logged for this.
There is two ways to fix this.
- member_affected needs added to the logAction data.
- Handle the null of $memID and set it to 0.
I'm omitting how to reproduce, because it seems like it may take very specific steps. But I would have to guess this can be triggered by a member requesting access to a group, the moderator acting on it and another member wanting to receive notifications of the action.
Environment (complete as necessary)
- Version/Git revision: 2.1.4
- Database Type: N/A
- Database Version: N/A
- PHP Version: 8.1