When switching to a user via the user profile and then choosing 'switch back' works fine for the admin. However logging out as admin and logging back in as the user that was switched to still shows the 'switch back' menu item in that users navigation block.

This is because the menu item 'switch back' is cached. Either put it outside $may_cache or clear the menu cache for that user upon switchback.

CommentFileSizeAuthor
#2 masquerade.module_1.patch1.21 KByched
#1 masquerade.module_0.patch843 bytesyched
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Status: Active » Needs review
FileSize
843 bytes

Reproduced in 4.7/cvs too.

I tested the "move out of $may_cache part in hook_menu' fix : it doesn't seem the right way, since the menu item is then no more available for configuration on page ?q=admin/menu

The included patch implements the other solution you propose, and it seems to do the job quite right.

This patch is against 4.7 version, BTW.

yched’s picture

FileSize
1.21 KB

Sorry, my patch was incomplete - in fact it corrected another similar bug :
1- logged as admin, masquerade as user1
2- log out (without switching back)
3- log in as user1
=> same problem, "switch back" menu item is still present.

Both issues should be fixed by this new patch

bwynants’s picture

it doesn't seem the right way, since the menu item is then no more available for configuration on page ?q=admin/menu

can you explain this? I do not quit get it...why should switchback be available in that menu?

yched’s picture

Status: Needs review » Fixed

Well, I guess it is a good thing that "switch back" menu item can be customized on the menu page, just like any other module-provided menu item.
Allows you to put it wherever you like in your menu hierarchy, organize things, stuff like that... The "navigation" menu can become quite once you installed a few modules...

Anyway it seems that merlin committed the patch a few days ago.
Maybe not for 4.6 though - that's probably why he didn't flag the issue as 'fixed' ?

merlinofchaos’s picture

I'm not sure why I didn't flag this as fixed, other than a braino. I committed the patch to both branches.

Actually, I might not have marked it fixed because it introduced another effect that I'm not happy with but is hard to rectify: If you're masquerading as someone, they will see the 'switch back' item too. And if they do something that causes the cache to refresh, switch back goes away for both of you.

This means I likely need to move it out of the cached menu settings, and use something in hook_settings() to control what menu it appears in, perhaps. If I can even control that.

Anonymous’s picture

Status: Fixed » Closed (fixed)