![]() |
Refresh iforumpermission cache
Hi.
I tried to retrieve each usergroup permission on a given forum using the getpermission(forumid,0,groupid) function. (it would be too complex doing that uprising the inheritance at database level ... as I tried to do days ago... :hurt: ) But noticed, cycling by the usergroup, a strange behavior based upon the order I tested the groups. Analyzing the code, I realized there's a kind of cache of permission stored each time in global environment. So, for example, if I test first usergroups 6 and 5, I get they CAN access to some forum. If I test them later, after some other groups, I get they CAN'T do the same access to the same forum. Question is simple: how could I bypass this 'cache-due' strange and unpredictable behavior ? Thank you very much. Hope someone could give an answer. Thanks |
Stick:
Code:
unset($permscache, $usergroupcache); |
Thanks. It seems working on cleaning cache... At least, when I
change the order of groups I call the function for, I always get the same results... But they are unexpected, mostly for usergroups 5 and 6 !!! :eek: I wrote this function (used a function to avoid some side effect coming from global variables not explicitly declared): PHP Code:
masks - I see Admin & Supermods can't access them. :rolleyes: Besides, I think there should be some cache interference yet, as - for example - if I test permissions by users with PHP Code:
I see the new group couldn't access that forum ... Instead, it can ! Even, i tried to unset the corresponding GLOBALS[] array variables, as I'm within a function... But results are the same. Any idea ? Thank you very much. |
You need [minicode]global $permscache, $usergroupcache;[/minicode] in the function.
|
Btw, OUTSIDE the function,
getpermission($forumid,$userid) doesn't work even on first 20 users. I get 'canview' access only for Admins... When the counter switches to Supermods, I get a "CAN'T" ... :( If I reverse the sort (counting users from 20 to 1), I get userids 6-8 (supermods) can access... Admins can't .... :eek Thnx |
For usergroup permissions (in particular for Mods & Supermods) the function behavior is unpredictable.
Where could I find into db such informations ? Thanks. Need help .... :( |
FF, you're very avaricious when we're talking about enhanced MySQL DB queries ... aren't you ? :D
After all, you can do it... Don't ? Quote:
:p |
Quote:
cache, even outside the function... If want, please try to upload this code to the admin/ directory and try to execute vs. some private/protected forum (&forumid=xx) and with moderator or supermods usergroup (&grpid=y). Even, a single user (&singleuser=uuu) can be specified. PHP Code:
- if the user belongs to the specified group, permissions are cached (i.e. wrong results if such user has single access mask set) - if not, permissions returned are true (reflecting the actual user ones) - if you copy the same section of $singleuser also before the first getpermissions(), you'll obtain true values ANY CASE, much different from the same code at the end of the script. It means that permissions are cached per usergroup and per forum. And the unsets aren't enough .... :( Thank you for attention. Any idea ? Bye |
Ok, now I understand what is wrong. I'll try and fix it...
|
Quote:
Thanks. Let me know. Bye |
This is the weirdest issue, I have no idea...
|
Please, try and give a look if u have time.
I would manage to understand whether a group (and its members) has access to a forum analyzing only the DB.... Thanks |
Quote:
|
I neither check the code extensively, nor tested it, but at first glance, doesnt that seem wrong to you:
PHP Code:
What about using this instead: PHP Code:
Logician |
Yes, of course...
Simply I used that array to obtain PER GROUP permission scheme. Btw, there's a strange cache staying in memory every time I call the getpermission() function that make it returns strange and wrong results, depending on the order I check groups, for example, or users themselves... That's the point of this thread and I can't get on... ;( Thank you very much. Bye |
Quote:
|
I GOT IT !!!
:laugh: :laugh: :laugh: Finally I managed to create a almost simple algorithm to perform a search of all users having access to a given forum, at any level (usergroup/forumpermission/accessmask), with the right priority order, I think. Chen, as it's an extension of your hack "List users by access masks", if you agree, I would post my 'version' following that thread, or as a new thread as 3rd party addon to your version ?? Here are the simple starting thesis:[list=1][*]All usergroups have default 'usergroup.canview=[0/1]' access to each forum, unless different specification somewhere else. Table 'usergroup'; lowest priority.[*]Search for group-forum crossed permissions in 'forumpermission' table. First for forum parent items, later (w/ major priority) child forums. Different forumpermission.canview=[0/1]' specification than the previous default could revert it for that usergroup; medium priority.[*]As a result, I'll obtain all the usergroups with canview access [0/1] to the desired forum.[*]Exploding users for these groups, now I have all the users with group-level rights.[*]Now I can check per-user based auths, checking the 'access' table. Based upon the status of 'access.canview=[0/1]' for each user, I can remove or add that user to the previous list. Highest security priority.[*]Finally I have the complete (unordered, but isn't a problem for sql IN statement) list of users having (or not) access to that particular forum.[/list=1] This way, with ONLY four (4) queries (even they could be reduced with some nice LEFT JOIN, but wouldn't overload my algorithm complexity at this time... if someone... :D ), I should have taken care of any security items in the VBulletin scheme. This version works only for two-level categories, but I think an easy extension could be done for recursive multi-level approach. Iteration is human, recursion is divine... Hope this will work. Thank you. Bye |
All times are GMT. The time now is 11:44 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|