Fixed "Register using Google" (and probably others) creates xf_ip entry for action "avatar_update" with user_id=0

Steffen

Well-known member
Affected version
2.2.15
XF\Pub\Controller::setupConnectedRegistration calls XF\Service\User\Registration::applyAvatarFromUrl which in turn calls XF\Service\Avatar::updateAvatar which finally calls its own writeIpLog method. It seems like at this point in time XF::visitor()->user_id is still 0 which causes entries in xf_ip with action = avatar_update and user_id = 0. This log entry is wrong and probably unnecessary because later on another entry with action = register will be created that has the correct user_id.

This seems like a reasonable fix to me (i.e. don't log IPs on avatar "update" during registration):

Diff:
--- a/src/XF/Service/User/Registration.php
+++ b/src/XF/Service/User/Registration.php
@@ -432,6 +432,7 @@ class Registration extends \XF\Service\AbstractService
        {
            /** @var \XF\Service\User\Avatar $avatarService */
            $avatarService = $this->service('XF:User\Avatar', $this->user);
+           $avatarService->logIp(false);
            if (!$avatarService->setImage($tempFile))
            {
                return false;
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.16).

Change log:
Skip logging IPs when updating avatars during registration
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom