Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

RoleID in GDN_Role doubles everytime a new role is created

I've noticed something very odd with the version of Vanilla 2 that I'm integrating...

Whenever I create a new role, the RoleID for the new role is double the previous role id. Like this:

2, Guest
4, Applicant
8, Member role
16, Administrator
32, My new role
64, My other new role
...
131072, My last created role

The field is of type INT(11) ... no idea how big an INT that will allow.

Is this how it's supposed to work? Do I need to worry about the column reaching it's maximum allowed INT size/length?

Comments

  • Options
    lucluc ✭✭
    It's indeed the desired behaviour.

    There was already discussion about it (difficult to migrate old board with over xx roles).

    Do a search, you should find more info.
  • Options
    TimTim Operations Vanilla Staff

    <?php
    for ($a = 2147483647; $a > 0; $i *= 2) {
      $i = (!$i) ? 1 : $i;
      $r++;
      $a -= $i;
    }
    die('found '.$r.' available roles');
    ?>
    This quick script suggests that there are 31 'slots' for roles. The reason we did it this way is because of a pretty sweet method of data encapsulation which allows us to store all of a user's roles within a single number. It is called Bit Masking and you can read more about it here http://en.wikipedia.org/wiki/Bit_array. @Todd kind of loves bit masks... feel free to tease him about this :D

    We'll look into this question during the coming few weeks and see if we think we can significantly improve on the way its done without impacting speed.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Options
    SS ✭✭
    edited June 2010
    Yep. 30+ Roles is more than enough.
    You can set custom "role permissions" for your application (without creating a new role) by using AfterGetSession event.
Sign In or Register to comment.