[development] The static $perm variable in user_access reset erroneously

Ron Parker sysop at scbbs.com
Mon Nov 3 19:46:34 UTC 2008



David Metzler wrote: 




"I downloaded and looked at the code for user_access and I have one 
idea. I've had some problem intializing static structures to arrays 
or objects in certain versions of php. Try changing the definition 
of $perm as follows: 

static $perm = ''; 
if (!$perm) $perm = array(); 

See if that changes the caching behavior in your php rev." 



"Another minor point regarding this debug, Since you're not dumping 
all of the $perm variable, we don't really know that the user_id is 
the same. What if the user_id was being checked? (we know which was 
being modified) Would recommend debugging print_r($account,1) and 
print_r($perm,1) after the reset line. " 


I've added a var_export command to dump the values from both $account and $var . I'm also using the $perm definition suggested above. 




This is the initial call to user_access to flush the $perm variable: 

    • ogur | module to call = node_content | type = story 
    • ogur | Preparing to call module_invoke 
    • ogur | Calling user_access('ClearCache', NULL, TRUE) 
    • user_access | string = ClearCache 
    • user_access | static $perm is NOT already set 
    • user_access | $perm set for uid 3 (test01) 
    • user_access | string = ClearCache | $perm values = 0,1,2,0,1,2,4,5,7,8,9,10,4,5,6,7,8,9,10,0,0,1,2,3,4 
    • user_access | roles returned: (authenticated user,Devel,Group Member,Group Contributor,Group Admin) 
    • user_access | permissions returned (end of function): (access comments,access content,view uploaded files,view advanced help index,view advanced help popup,view advanced help topic,post comments,post comments without approval,search content,use advanced search,subscribe to newsletters,view links in block,create page content,create story content,delete own page content,delete own story content,edit own page content,edit own story content,upload files,configure member roles,access devel information,display source code,execute php code,switch users,view devel_node_access information) 
    • user_access | $account : class stdClass { var $uid = '3'; var $name = 'test01'; var $pass = ''; var $mail = ''; var $mode = '0'; var $sort = '0'; var $threshold = '0'; var $theme = ''; var $signature = ''; var $created = '1214004001'; var $access = '1225742808'; var $login = '1225218681'; var $status = '1'; var $timezone = NULL; var $language = ''; var $picture = ''; var $init = 'test01 at scbbs.com'; var $data = 'a:3:{s:13:"form_build_id";s:37:"form-828fb54ceb43bf0d467b9dcc20cebfd7";s:21:"og_user_roles_regcode";s:0:"";s:8:"og_email";s:1:"1";}'; var $timezone_id = '0'; var $form_build_id = 'form-828fb54ceb43bf0d467b9dcc20cebfd7'; var $og_user_roles_regcode = ''; var $og_email = '1'; var $roles = array ( 2 => 'authenticated user', 8 => 'Devel', 3 => 'Group Member', 4 => 'Group Contributor', 7 => 'Group Admin', ); var $og_groups = array ( 24 => array ( 'title' => 'USADance LA', 'type' => 'group', 'status' => '1', 'nid' => '24', 'og_role' => '0', 'is_active' => '1', 'is_admin' => '0', 'uid' => '3', 'mail_type' => NULL, 'created' => '1225139825', 'changed' => '1225139825', ), ); } 
    • user_access | $perm : array ( 3 => array ( 'access comments' => 0, 'access content' => 1, 'view uploaded files' => 2, 'view advanced help index' => 0, 'view advanced help popup' => 1, 'view advanced help topic' => 2, 'post comments' => 4, 'post comments without approval' => 5, 'search content' => 7, 'use advanced search' => 8, 'subscribe to newsletters' => 9, 'view links in block' => 10, 'create page content' => 4, 'create story content' => 5, 'delete own page content' => 6, 'delete own story content' => 7, 'edit own page content' => 8, 'edit own story content' => 9, 'upload files' => 10, 'configure member roles' => 0, 'access devel information' => 0, 'display source code' => 1, 'execute php code' => 2, 'switch users' => 3, 'view devel_node_access information' => 4, ), ) 


This is the next call to user_access should contain the values of $perm from above, but don't. 

    • ogur | Calling module_invoke('node_content', 'access', 'create', 'story', $user) 
    • node_content_access | type = story | op = create 
    • node_content_access | roles returned: (authenticated user,Devel,Group Member,Group Contributor,Group Admin) 
    • user_access | string = create story content 
    • user_access | static $perm is already set 
    • user_access | string = create story content | $perm values = 0,1,2,3,4,5,6,7,8,9,10,0,1,2,3,4 
    • user_access | roles returned: (authenticated user,Devel,Group Member,Group Contributor,Group Admin) 
    • user_access | permissions returned (end of function): (view advanced help index,view advanced help popup,view advanced help topic,access comments,post comments,post comments without approval,access content,search content,use advanced search,subscribe to newsletters,view links in block,access devel information,display source code,execute php code,switch users,view devel_node_access information) 
    • user_access | $account : class stdClass { var $uid = '3'; var $name = 'test01'; var $pass = ''; var $mail = ''; var $mode = '0'; var $sort = '0'; var $threshold = '0'; var $theme = ''; var $signature = ''; var $created = '1214004001'; var $access = '1225742808'; var $login = '1225218681'; var $status = '1'; var $timezone = NULL; var $language = ''; var $picture = ''; var $init = 'test01 at scbbs.com'; var $data = 'a:3:{s:13:"form_build_id";s:37:"form-828fb54ceb43bf0d467b9dcc20cebfd7";s:21:"og_user_roles_regcode";s:0:"";s:8:"og_email";s:1:"1";}'; var $timezone_id = '0'; var $form_build_id = 'form-828fb54ceb43bf0d467b9dcc20cebfd7'; var $og_user_roles_regcode = ''; var $og_email = '1'; var $roles = array ( 2 => 'authenticated user', 8 => 'Devel', 3 => 'Group Member', 4 => 'Group Contributor', 7 => 'Group Admin', ); var $og_groups = array ( 24 => array ( 'title' => 'USADance LA', 'type' => 'group', 'status' => '1', 'nid' => '24', 'og_role' => '0', 'is_active' => '1', 'is_admin' => '0', 'uid' => '3', 'mail_type' => NULL, 'created' => '1225139825', 'changed' => '1225139825', ), ); } 
    • user_access | $perm : array ( 3 => array ( 'view advanced help index' => 0, 'view advanced help popup' => 1, 'view advanced help topic' => 2, 'access comments' => 3, 'post comments' => 4, 'post comments without approval' => 5, 'access content' => 6, 'search content' => 7, 'use advanced search' => 8, 'subscribe to newsletters' => 9, 'view links in block' => 10, 'access devel information' => 0, 'display source code' => 1, 'execute php code' => 2, 'switch users' => 3, 'view devel_node_access information' => 4, ), ) 
    • ogur | module_invoke called 
    • ogur | ognodeadd roles returned: (authenticated user,Devel,Group Member,Group Contributor,Group Admin) 
    • ogur | module_invoke access returns false 


Again, this problem only occurs, so far, when I have one of these modules installed along with OGUR: tac_lite, taxonomy_access, menu_breadcrumb and admin_menu . Other modules with which I'm told this problem occurs: 

    • Content Permissions 
    • Localization client 

I've searched the code of these modules for some indication of their modifying the $perm variable, but can find none. 

I do really appreciate the help. This is driving me nuts! I can find no logical explanation for this modification, thus I'm unable to figure out a way around it. 

-ron 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20081103/511df441/attachment-0001.htm 


More information about the development mailing list