In the same way that hook_taxonomy gets called to update term_access when a term is deleted, term_access should get updated when a role is removed. Currently this only happens when the module is disabled and enabled in function _taxonomy_access_update_db.

Comments

xjm’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev

I believe this is still an issue in the 6.x branch; need to test.

xjm’s picture

Assigned: Unassigned » xjm

Working on this. (Thank goodness D7 supports foreign keys... if only D6 did.)

xjm’s picture

Priority: Normal » Minor

I never realized this before, but there are no hooks associated with role deletion:
http://api.drupal.org/api/function/user_admin_role/6
http://api.drupal.org/api/function/user_admin_role_validate/6
http://api.drupal.org/api/function/user_admin_role_submit/6

So, without referential integrity, all we could do is add form overrides to clean out the stale data.

Dialing this down to minor since it doesn't affect functionality and the number of roles tends to be small in comparison to other data types.

xjm’s picture

Assigned: xjm » Unassigned
xjm’s picture

One place we might be able to do this cleanup without much overhead is on visits to the admin page. That form already checks the list of existing roles against those found in TAC tables.

keve’s picture

Title: Clean up term_access when a role gets deleted » Hook_user missing: Clean up term_access when a role gets deleted

There is a need to add hook_user ffor role deletion in TAC. As i see, it is missing.

xjm’s picture

hook_user() doesn't get invoked when a role is deleted, though, not that I can see. (See in http://api.drupal.org/api/function/user_admin_role_submit/6). That's the problem. (There is a hook for it in D7, though.)

keve’s picture

Title: Hook_user missing: Clean up term_access when a role gets deleted » Clean up term_access when a role gets deleted (No hook for role deletion in D6)

You're right. I checked: user_admin_role_submit().
I forget about it. That can be why i have not inserted hook_user into TAC before.

Your idea in comment #5 seems ok. OR we should postpone this until D7 version.

xjm’s picture

Status: Active » Postponed

That seems reasonable too.

xjm’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Category: bug » task
Status: Postponed » Active
xjm’s picture

In D7 we can merely implement hook_user_role_delete().

xjm’s picture

Title: Clean up term_access when a role gets deleted (No hook for role deletion in D6) » Clean up term_access when a role gets deleted
Status: Active » Fixed

Status: Fixed » Closed (fixed)

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