menu_get_item() doesn't set 'map' property in the item when access is denied

Created on 23 May 2013, almost 12 years ago
Updated 24 April 2024, 11 months ago

menu_get_item() only sets the $item['map'] if the user has access to the menu item.

However, the documentation does not say that the map property is conditional:

The router item or, if an error occurs in _menu_translate(), FALSE. A router item is an associative array corresponding to one row in the menu_router table. The value corresponding to the key 'map' holds the loaded objects.

Is there any reason it's omitted if there's no access? If not, it would be more consistent to always include it.

🐛 Bug report
Status

Active

Version

7.0 ⚰️

Component
Menu system 

Last updated 2 days ago

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Truly, it is not just 'map' that is not set; 'page_arguments' and 'theme_arguments' are not even unserialize()'d.

    if ($router_item['access']) {
      $router_item['map'] = $map;
      $router_item['page_arguments'] = array_merge(menu_unserialize($router_item['page_arguments'], $map), array_slice($map, $router_item['number_parts']));
      $router_item['theme_arguments'] = array_merge(menu_unserialize($router_item['theme_arguments'], $map), array_slice($map, $router_item['number_parts']));
    }
    

    It seems early optimization which could cause issues. Code that checks whether the currently logged user has access to the router item relies on $router_item['access'], not $router_item['map'].

Production build 0.71.5 2024