setupLogEntityActor can throw if moderator actions are triggered from CLI

Xon

Well-known member
Licensed customer
Affected version
2.3.10
PHP:
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.
 
Back
Top Bottom