I just realized, that the static cache of og_get_user_roles() function should be resetted before other modules may react on this actions via hook_og_role_revoke(). This is already done for hook_og_role_grant() (see og_role_grant() -> there is a og_invalidate_cache() call before the hook calls).

This is especially important for Rules conditions, because you cannot check OG roles in a rule that reacted on the "OG role revoked from user" event, because the revoked role is still stuck in the static cache.

CommentFileSizeAuthor
#1 invalidate-cache-on-role-revoke.patch413 byteshctom
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hctom’s picture

hctom’s picture

Status: Active » Needs review
hctom’s picture

Just a little workaround for everybody else experienceing this issue:

Just put the following hook in one of your modules

/**
 * Implements hook_og_role_revoke().
 */
function MODULE_NAME_og_role_revoke($group_type, $gid, $uid, $rid) {
  og_invalidate_cache();
}
amitaibu’s picture

Status: Needs review » Fixed

Committed, thanks.

  • Commit 20ae54f on 7.x-2.x authored by hctom, committed by Amitaibu:
    Issue #2233365 by hctom: Static cache reset during OG role revoke.
    
hctom’s picture

You're welcome ;)

Status: Fixed » Closed (fixed)

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