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

Fixed Function "isMemberOfUserGroup" - empty $userGroupId

Discussion in 'Resolved Bug Reports' started by cclaerhout, Nov 6, 2014.

  1. cclaerhout

    cclaerhout Well-Known Member

    This is not really a bug, but still deserves to be checked. When the template helper "ismemberof" is used and its second parameter is null and not an empty array (which is certain coming from an incorrectly thinking implementation of perms of my addon), "true" is returned because of this:

    Class: XenForo_Model_User
    strpos(",{$user['secondary_group_ids']},"",{$userGroupId},") !== false
    The unregistered visitor secondary usergroups ids are blanked, so when the $userGroupId is blanked too the position is found at 0, so is not false.

    Since the usergroup id "0" doesn't exist, the easiest "fix" for the content to be perfectly safe is to put at the top of the function a simple check:
    This should break nothing with existing coding and would avoid an extra template conditional check of the $userGroupId variable.
    Last edited: Nov 6, 2014
    Xon and Nobita.Kun like this.
  2. Mike

    Mike XenForo Developer Staff Member

    I have added the additional check, though I would definitely check any calling code in this case. :)
    cclaerhout likes this.
  3. cclaerhout

    cclaerhout Well-Known Member

    Already checked and found the problem on my side. Thank you for this little check implementation.

Share This Page