1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Not a Bug Unreachable code?

Discussion in 'Resolved Bug Reports' started by Liam W, Sep 1, 2014.

  1. Liam W

    Liam W Well-Known Member

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

    if (!$addGroups)
    (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?

  2. Mike

    Mike 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).

Share This Page