Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-14-2002, 10:10 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 05-15-2002, 09:29 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Stick:
Code:
unset($permscache, $usergroupcache);
Before calling getpermissions().
Reply With Quote
  #3  
Old 05-15-2002, 04:56 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 !!!

I wrote this function (used a function to avoid some side effect
coming from global variables not explicitly declared):
PHP Code:
function testugperm($forum2test=9) {
    global 
$DB_site;

    
$usergroups=$DB_site->query("SELECT usergroupid,title FROM usergroup ORDER BY usergroupid");

    echo 
"<p><pre>";
    while (
$usergroup=$DB_site->fetch_array($usergroups)) {

        unset(
$permscache$usergroupcache);
        
$perms=getpermissions($forum2test,0,$usergroup[usergroupid]);

        if (
$perms[canview])
            echo 
"<br>Forum <b>$forum2test</b> <b> can </b> be accessed by usergroup $usergroup[usergroupid] ($usergroup[title])";
        else
            echo 
"<br>Forum <b>$forum2test</b> <b>can't</b> be accessed by usergroup $usergroup[usergroupid] ($usergroup[title])";
    }
    echo 
"</pre></p>";

but - even on public forums or private without specific access
masks - I see Admin & Supermods can't access them.

Besides, I think there should be some cache interference yet, as -
for example - if I test permissions by users with
PHP Code:
        unset($permscache$usergroupcache);
        
$perms=getpermissions($forum2test,$userid); 
for first 20 users, when the cycle passes from a group to another,
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.
Reply With Quote
  #4  
Old 05-15-2002, 04:59 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need [minicode]global $permscache, $usergroupcache;[/minicode] in the function.
Reply With Quote
  #5  
Old 05-15-2002, 05:08 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 05-16-2002, 09:03 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For usergroup permissions (in particular for Mods & Supermods) the function behavior is unpredictable.
Where could I find into db such informations ?

Thanks.
Need help ....
Reply With Quote
  #7  
Old 05-18-2002, 07:11 AM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

FF, you're very avaricious when we're talking about enhanced MySQL DB queries ... aren't you ?

After all, you can do it... Don't ?
Quote:
We have done so much, for so long, with so little, we are now qualified to do anything with nothing.
Thanks
Reply With Quote
  #8  
Old 05-18-2002, 10:43 AM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by FireFly
Stick:
Code:
unset($permscache, $usergroupcache);
Before calling getpermissions().
There's something not working. I can't manage to clean the
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:
<?php
error_reporting
(E_ALL);

require(
"./global.php");
cpheader();

echo 
"<p>Group <b>$grpid</b> crossed with Forum <b>$forumid</b></p>";

if (isset(
$forumid) and isset($grpid)) {

   
$forum2test=$forumid;

    
$usergroups=$DB_site->query("SELECT usergroupid,title FROM usergroup where usergroupid=$grpid");

    echo 
"<p>";
    while (
$usergroup=$DB_site->fetch_array($usergroups)) {

        
$id=$usergroup[usergroupid];

        
$perms[$id]=getpermissions($forum2test,0,$id);

        
$k=$perms[$id];
        if (
$k[canview])
            echo 
"<br>Forum <b>$forum2test</b> <b> can </b> be accessed by usergroup $usergroup[usergroupid] ($usergroup[title])";
        else
            echo 
"<br>Forum <b>$forum2test</b> <b>can't</b> be accessed by usergroup $usergroup[usergroupid] ($usergroup[title])";
    }
    echo 
"</p>";


    
$users=$DB_site->query("SELECT userid,username FROM user WHERE usergroupid=$grpid ORDER BY userid");

    echo 
"<p>";
    while (
$user=$DB_site->fetch_array($users)) {

        unset(
$permscache$usergroupcache);

        
$id=$user[userid];

        
$permuser[$id]=getpermissions($forum2test,$id);

        
$k=$permuser[$id];
        if (
$k[canview])
            echo 
"<br>Forum <b>$forum2test</b> <b> can </b> be accessed by user $user[userid] ($user[username])";
        else
            echo 
"<br>Forum <b>$forum2test</b> <b>can't</b> be accessed by user $user[userid] ($user[username])";
    }
    echo 
"</p>";


    
// copy this code right before the first select...
    
if (isset($singleuser)) {

        unset(
$permscache$usergroupcache);

        
$user[userid]=$singleuser;
        
$permsingleuser=getpermissions($forum2test,$user[userid]);

        if (
$permsingleuser[canview])
            echo 
"<br>Forum <b>$forum2test</b> <b> can </b> be accessed by user $user[userid]";
        else
            echo 
"<br>Forum <b>$forum2test</b> <b>can't</b> be accessed by user $user[userid]";

    }
    
//  ... and if run with an user of the usergroup specified,
    //  you'll get different values for same instructions.

}

echo 
"<br><br><p>Performance stats: <b>".number_format($query_count)."</b> queries done in <b>".number_format($querytime,7)."</b> seconds</p>";

cpfooter();

?>
You can notice if run with a single user, that:
- 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
Reply With Quote
  #9  
Old 05-18-2002, 12:03 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, now I understand what is wrong. I'll try and fix it...
Reply With Quote
  #10  
Old 05-20-2002, 08:04 AM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by FireFly
Ok, now I understand what is wrong. I'll try and fix it...
Here I'm ! I rely on you...
Thanks.
Let me know.
Bye
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:38 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04984 seconds
  • Memory Usage 2,300KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (3)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete