When you remove a user from a given role, the effect is often not seen for a long time since the user's menu remains in cache. we should invaidate the menu cache for a user whenh is roles change (or anytime the $user is saved?).

This same bug is apparent when you grant new roles to a user.

CommentFileSizeAuthor
#1 menu_18.patch1.51 KBjonbob

Comments

jonbob’s picture

StatusFileSize
new1.51 KB

Fixed by adding ability to invalidate cache only for one user.

Anonymous’s picture

Don't we also need some code in user.module to call menu_rebuild?

jonbob’s picture

Yes, the patch does that.

dries’s picture

I think the user module needs more work (last two chunks added by me):

diff -r1.434 user.module
199a200,202
>
>   // Rebuild this user's menu to account for possibly changed permissions.
>   menu_rebuild($user->uid);
1135,1136d1137
<         // Delete that user's menu cache.
<         cache_clear_all('menu:'. $account->uid);
1442d1442
<     cache_clear_all();

Please verify/update as necessary.

(I, for one, wouldn't expect menu_rebuild() to flush the page cache.)

jonbob’s picture

I guess I don't have a strong opinion on this. Calling menu_rebuild() does the necessary cache clearing, but if this is deemed hard to understand, then just clearing the cache may be sufficient. However, we use menu_rebuild() in other places for this purpose; should those be changed to a set of cache clears instead?

The difference between menu_rebuild() and just doing the cache clears is:
- menu_rebuild() fixes the menu for the current page request, not just for future ones.
- menu_rebuild() populates the menu table with newly added module-defined items.

dries’s picture

Whatever we choose to do, the current patch does not improve consistentcy. Just look at the existing code to clear the menu cache, and unify it into one function.

killes@www.drop.org’s picture

I guess Dries won't commit it as is.

killes@www.drop.org’s picture

Status: Active » Fixed

This is fixed in cvs.

Anonymous’s picture

Status: Fixed » Closed (fixed)