When a user role is deleted, other modules don't get informed, leaving outdated incorrect data in module tables that store user roles relationships.

In core, at least {book_role} and {filter_format} store roles relationships.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dropcube’s picture

Priority: Normal » Critical
Status: Active » Needs review
FileSize
2.97 KB

This patch introduces hook_user_role_delete, a hook that would allow modules to act when a use role is deleted.

The hook is implemented in filter.module and block.module.

I am marking this critical, to get some attention before the freeze, as this introduces a new hook (API), .

Dries’s picture

I agree that this is a useful function, but shouldn't we have hooks for adding and updating too -- for consistency?

dropcube’s picture

but shouldn't we have hooks for adding and updating too -- for consistency?

Currently, I can't see a case when a module might need to act when a role is updated (role name changed), but might be later. So, yes, for consistency.

dropcube’s picture

Title: User system doesn't communicate with modules about deleted roles » User system doesn't communicate with modules about roles: add user roles API
FileSize
6.32 KB

This patch adds:

- API functions to manipulate user roles: user_role_load($rid), user_role_save($role), user_role_delete($role)
- hooks hook_user_role_insert($role), hook_user_role_update($role), hook_user_role_delete($role)
- Implementation of hook_user_role_delete() in core modules filter.momdule and block.mdoule

dropcube’s picture

tagging

dropcube’s picture

Category: bug » task
Issue tags: +API change, +API addition

Tagging.

moshe weitzman’s picture

@dropcube could you look at the patch at #300993: User roles and permissions API and borrow the testing code and anything else that makes sense? then continue this fine work here or there.

dropcube’s picture

Status: Needs review » Closed (duplicate)

Ok, I will take that issue, marking this as duplicate.