og_user_roles_og() mistakenly deletes existing roles on 'user update' if not admin

heacu - August 28, 2009 - 12:54
Project:OG User Roles
Version:6.x-4.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

hi,

typo in following code causes ALL preexisting roles to be lost for example when a user's status is changed from active=0 to active=1. this is because $rid hasn't been set. probably

og_user_roles_role_delete($nid, $uid, $rid);

should be changed to

og_user_roles_role_delete($nid, $uid, $default_admin_role);

case 'user update':
$default_admin_role = variable_get('og_user_roles_default_admin_role', 0);
$default_role = variable_get('og_user_roles_default_role', 0);
if ($default_admin_role > 0 && $default_admin_role != $default_role) {
// Grant role for new group admin.
if (isset($args['is_admin']) && $args['is_admin']) {
og_user_roles_role_add($nid, $uid, $default_admin_role);
}
// Delete role for obsolete group admin.
else {
og_user_roles_role_delete($nid, $uid, $rid);
}
}
break;

#1

heacu - October 11, 2009 - 18:48

as a follow up, i just tested this fix and it appears to work. the problem was that $rid was not defined anywhere in

function og_user_roles_og($op, $nid, $uid, $args = array()) {

so the line og_user_roles_role_delete($nid, $uid, $rid); ended up deleting ALL group roles for the user.

#2

miro_dietiker - October 16, 2009 - 16:15
Status:active» needs work

Hmm... ugly.
Can you please provide a patch against cvs? It will get reviewed soon and can get fixed.
http://drupal.org/patch/create

#3

sun - November 11, 2009 - 03:25
Title:og_user_roles_og mistakenly deletes all existing roles on 'user update' if not admin» og_user_roles_og() mistakenly deletes existing roles on 'user update' if not admin
Status:needs work» active

Please provide a proper patch. I'm unable to read changes you did from your post.

#4

pwolanin - November 13, 2009 - 19:36

It looks like this bug was already fix in this commit: http://drupal.org/cvs?commit=232194

#5

sun - November 13, 2009 - 21:16
Status:active» fixed

oopsie, looks like it's time for a new stable then ;)

Thanks, pwolanin! :-D

#6

System Message - November 27, 2009 - 21:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.