When I upgraded a buyer to add a new role on purchase i get two entries in the watchdog log.
Adding bill to role .
Adding bill to role subscriber.
The role being added is "subscriber", but it appears a blank watchdog entry gets added, cluttering up the log. I don't think there are any critical side effects from this.
Offending code starts around line 922:
// If PAID - add user to role, else drop 'em
if ($add_to_roles) {
foreach($on_payment_roles as $rid => $rname) {
if (!isset($u->roles[$rid])) {
watchdog('ecommerce', t('Adding %name to role %role.', array('%name' => theme('placeholder', $u->name), '%role' => theme('placeholder', $roles[$rid]))));
$u->roles[$rid] = '';
}
}
user_save($u, array('roles' => $u->roles));
}
Comments
Comment #1
dvdweide commentedThe empty 'role' is caused by the drupal variable "on_payment_roles" which is an array of all available roles with the roleid as key and the roleid or 0 as value. This array gets flipped (array_flip) which creates a key 0 if not all available roles were selected.
The result is that the buyer also gets added to the non-existing role 0.
A simple solution is checkin $rid for zero values. See attached patch!
Cheers, Danny
Comment #2
dvdweide commentedBTW, it also occurs in cvs
Danny
Comment #3
simeThanks @dvdweide, applied to CVS. Won't backport as it is not critical
http://drupal.org/cvs?commit=36360
Comment #4
(not verified) commented