RSS Feed/News setupLogEntityActor can throw if moderator actions are triggered from CLI

Status
Not open for further replies.

ENXF NET

Administrator
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P.S Member
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Nov 13, 2018
Messages
31,343
Points
823

Reputation:

PHP:

Code:
protected function setupLogEntityActor(ModeratorLog $log, User $actor)
{
    $log->user_id = $actor->user_id ?? 0;

if ($actor->user_id == \XF::visitor()->user_id)
    {
        $log->ip_address = Ip::stringToBinary(\XF::app()->request()->getIp());
    }
}

By default stringToBinary will throw if passed an invalid IP, but ModeratorLog will accept an empty ip address for example if this code gets invoked from the CLI where no IP address for the request exists.

Continue reading...
 
Status
Not open for further replies.
Top