Not a bug Unreachable code?

Liam W

Well-known member
In the library/XenForo/User.php file, this code is in the addUsergroupChange method:

if (!$addGroups)
    return true;
(Lines 1510-1513)

A few lines below, there is this block:

if (isset($newGroups[$key]) && !$addGroups)
        // already exists and we're removing the groups, so we can just remove the record
        return $this->removeUserGroupChange($userId, $key);
(Lines 1519-1523)

Surely the code in the second if statement will never run, as if it the statement were to pass, the first if statement would have run and therefore stopped the method?



XenForo developer
Staff member
You're probably right that it's unreachable as the behavior may have changed over time. I would say that unreachable code isn't generally a bug though (especially when it's just down to one condition).