an issue in role_watchdog to get their opinion about how to integrate with ubercart (uc_roles): #1142950: integrate with ubercart and uc_roles
Maybe ubercart can do something like #341162: Module should use user_save instead of directly accessing drupal database (drupal5 patch). Is there a reason not to?
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | uc_roles-user_save.patch | 1000 bytes | john.money |
Comments
Comment #1
yesct commentedhmmm. uc_roles does seem to use user_save:
around line 1177 of uc_roles.module:
and around 1224
Comment #2
john.money commenteduc_roles_revoke() and uc_roles_grant() both modify the $account object before user_save() is done. So when another module attempts to identify any role changes, it cannot detect any since $account already reflects the new role state. This is not necessary, since user_save will return a fully-built $user object.
Here is example:
At line 1174 of uc_roles.module in function uc_roles_revoke()
If however, I change that line to:
...we are able to compare the previous $account with the new $edit values.
Attached is a patch to uc_roles which should (very light testing) preserve all uc_roles behavior while still letting user_save do its thing.
Comment #3
yesct commentedI tested it, and it lets roles added by uc be tracked.
Comment #4
longwaveCommitted to 6.x, thanks for the patch.
Comment #5
longwaveThis applies cleanly to 7.x but not sure if it's needed, as D7 core user_save() looks like it provides $account->original to compare against in hooks.
Comment #6
longwaveComment #7
longwaveCommitted to 7.x anyway to minimise changes between versions.
Comment #9
yesct commentedmy code for ubercart is updated, and I manually checked that the changes from that patch were included, and they are, but. expiring roles granted via uc_roles feature are not logged in the Roles tab (via roles watchdog). Maybe something else with uc or role watchdog has changed.
Comment #10
yesct commentedI have: 6.x-1.2 role watchdog and 6.x-2.7 ubercart roles