Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#2 | masquerade.module_1.patch | 1.21 KB | yched |
#1 | masquerade.module_0.patch | 843 bytes | yched |
Comments
Comment #1
yched CreditAttribution: yched commentedReproduced 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.
Comment #2
yched CreditAttribution: yched commentedSorry, 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
Comment #3
bwynants CreditAttribution: bwynants commentedcan you explain this? I do not quit get it...why should switchback be available in that menu?
Comment #4
yched CreditAttribution: yched commentedWell, 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' ?
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedI'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.
Comment #6
(not verified) CreditAttribution: commented