Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.4.0

Request #7041 getRights() on an unassigned group returns nothing
Submitted: 2006-03-06 23:07 UTC
From: msadagopan at wltcapital dot com Assigned: lsmith
Status: Analyzed Package: LiveUser_Admin (version 0.3.7)
PHP Version: 5.1.2 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2006-03-06 23:07 UTC] msadagopan at wltcapital dot com (Madhu Sadagopan)
Description: ------------ Package Version State LiveUser 0.16.10 beta LiveUser_Admin 0.3.7 beta System Linux ubuntu 2.6.12-10-386 #1 Mon Feb 13 12:13:15 UTC 2006 i686 Build Date Feb 21 2006 10:09:40 './configure' '--with-apxs2=/usr/bin/apxs2' '--with-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-mysql-sock=/tmp/mysql.sock' '--with-sqlite' '--enable-sqlite-utf8' '--with-zlib' '--with-zlib-dir' '--with-bz2' '--with-gd' '--enable-gd' '--enable-gd-native-ttf' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-ttf' '--with-freetype-dir=/usr/local' '--with-iconv=/usr/local' '--with-curl=/usr/local' '--enable-track-vars' '--with-gettext' '--with-config-file-path=/etc/apache2' '--enable-trans-id' '--enable-ftp' '--enable-mbstring' '--with-tidy' '--with-xsl' Test script: --------------- //LUA -> LiveUser_Admin $data = array('application_define_name' => 'APP_WORLD'); $app_id = $LUA->perm->addApplication($data); $data = array( 'application_id' => $app_id, 'area_define_name' => 'AREA_FOO',); $area_id = $LUA->perm->addArea($data); $data = array( 'area_id' => $area_id, 'right_define_name' => 'INSERT', 'has_implied' => FALSE); $right_id = $LUA->perm->addRight($data); $data = array( 'group_define_name' => 'GRP_TEST'); $group_id = $LUA->perm->addGroup($data); $data = array( 'group_id' => $group_id, 'right_id' => $right_id, 'right_level' => '1'); $granted = $LUA->perm->grantGroupRight($data); $params = array( 'fields' => array('right_id','right_define_name','right_level'), 'filters' => array('group_id' => $group_id), 'by_group' => TRUE,); $grp_rights = $LUA->perm->getRights($params, TRUE); print_r($grp_rights); Expected result: ---------------- array(1) { [0]=> array(3) { ["right_id"]=> string(3) "<right_id>" //the $right_id ["right_define_name"]=> string(6) "INSERT" ["right_level"]=> string(1) "1" } Actual result: -------------- array(0) The final generated query @ LiveUser/Admin/Storage/SQL.php in the function select() SELECT liveuser_rights.right_id AS right_id, liveuser_rights.right_define_name AS right_define_name, liveuser_grouprights.right_level AS right_level FROM liveuser_rights, liveuser_groupusers, liveuser_grouprights WHERE liveuser_rights.right_id = liveuser_grouprights.right_id AND liveuser_grouprights.group_id = liveuser_groupusers.group_id AND liveuser_groupusers.group_id = 27 Its joining the 'liveuser_groupusers' table also. But in this case, since a user hasn't been assigned to the group 'GRP_TEST', getRights() returns nothing.

Comments

 [2006-03-07 07:35 UTC] lsmith
You are using a pre-release API. We changed it before the release to be more consistent. From the changelog: - added "by_group" optional parameter to params getRights() which determines if the userrights table should be used or rather the grouprights and groupupsers tables
 [2006-03-07 18:40 UTC] msadagopan at wltcapital dot com
I don't think you understood the actual issue. For a context, we're working on a group rights editor. If we create a group, but it has no users yet, it should still be possible to manage the rights of that group before assigning a user to the group. However at the moment it is not possible due to getRights() creating an SQL query that unnecessarily joins the liveuser_groupusers table: WHERE liveuser_rights.right_id = liveuser_grouprights.right_id AND liveuser_grouprights.group_id = liveuser_groupusers.group_id AND liveuser_groupusers.group_id = 27 But what it should be: WHERE liveuser_rights.right_id = liveuser_grouprights.right_id AND liveuser_grouprights.group_id = 27 There is no data being requested from liveuser_groupusers, nor it that being used for any filtering, so shouldn't be involved in the query. What we are requesting is this behavior, to support group rights management before users have been added to the group.
 [2006-03-07 18:45 UTC] lsmith
Could you specifiy the exact getRights() call you are talking about? ---- your example: $params = array( 'fields' => array('right_id','right_define_name','right_level'), 'filters' => array('group_id' => $group_id), 'by_group' => TRUE,); $grp_rights = $LUA->perm->getRights($params, TRUE); --- - note that the second parameter to getRights is bogus (that got me confused). - the 'fields' you specify there should indeed only cause a join to the grouprights and rights table
 [2006-03-07 19:16 UTC] msadagopan at wltcapital dot com
We are using the the Complex container and its the getRights() function defined at Line - 815 in /<pear-dir>/LiveUser/Admin/Perm/Complex.php Regarding the bogus second parameter, The documentation still has the second bogus parameter, even in the latest source tree of Complex.php which is at revision 1.86 The expected result, which you seem to agree is how it should be, didn't match with the actual result even after removing the bogus second parameter because its not being used anyway. $params = array( 'fields' => array('right_id','right_define_name','right_level'), 'filters' => array('group_id' => $group_id), 'by_group' => TRUE,); $grp_rights = $LUA->perm->getRights($params);
 [2006-03-07 22:20 UTC] lsmith
I knew this day would come. I need to rewrite the entire join generator to a smarter search algorithm that looks for the least joins instead of the first possible join order to find all columns. For now a solution might be to override the selectable tables: $LUA->perm->selectable_tables['getGroups'] = array('groups', 'grouprights', 'rights', 'groupusers', 'translations'); Might break things on another end though. The problem is that currently the join finder simply goes through the ordered list of selectable tables, looking to match the entire list of columns being operated on. This means it may end up joining 3 tables instead of just 2. This is non obvious and inefficient too.
 [2006-03-08 13:53 UTC] lsmith
I have added support for passing in the selectable_tables array as part of the params array in get*() method calls in CVS. Still not a solution, but makes hacking around this issue easier.
 [2006-06-26 16:13 UTC] kezban11 at gmx dot de (Veysel Özer)
i had a similar problem with LiveUser_Admin 0.3.8 i added following line to the admin/perm/medium.php constructor $this->selectable_tables['getRights'][] = 'grouprights'; i think this is simply missing there, cause when looking to the complex.php you'll see that there is $this->selectable_tables['getRights'][] = 'right_implied'; hope that's also what you're talking about
 [2006-08-14 08:45 UTC] lsmith (Lukas Smith)
BTW: when we do the rewrite we should probably also move to using ANSI JOIN syntax to open up the possibility of supporting OUTER JOINs