- Issue created by @kle
[edit] sorry, but my analytics was wrong - here the correct idea. Its not a bug, but I have a "Feature"-Request.
Wrong menu-Links can be shown if HOOK_menu_admin_per_menu_get_permissions_alter is used.
Use HOOK_menu_links_discovered_alter() to add a link to a menu "my_menu"
Use HOOK_menu_admin_per_menu_get_permissions_alter to give permission to this menu to userA - not to userB
userA and userB must have same roles !!!
Login with userA and userB in different browsers
Clear cache and reload for userA: he will see the Link to "my_menu" - reload userB: he sees this link too !!!
Clear cache and reload for userB: now he wont see the link to "my_menu"- reload for userA: he also cant see.
This showcase has menus which differ PER USER. So adding a cache-context has helped in my case.
It would be fine to read some information about this problem in menu_admin_per_menu.api.php.
As example here my preprocess-hook:
function my_module_preprocess_menu(&$variables, $hook) {
// Add user as cache-context
$variables['#cache'] = ['contexts' => ['user']];
}
Write about this issue in menu_admin_per_menu.api.php
Active
1.5
Code