How to apply node access rules when querying menu_links table I am creating a custom block which displays a menu.  The menu is constructed by retrieving certain menu links from the menu_links table in the database. It has occurred to me that building it this way could introduce a security issue, in the situation that a user does not have permission to view a certain node, but that menu link is still included in in the custom block.

I am wondering if there is some way of filtering results obtained from menu_links table based on current user role?

Menu links are currently being retrieved with queries like this one:

// Get all siblings of parent menu.
$siblings = db_select('menu_links', 'ml')
  -&gt;fields('ml')
  -&gt;condition('plid', $target['plid'])
  -&gt;condition('hidden', 0)
  -&gt;orderBy('weight')
  -&gt;execute();


Actual menu structure is being constructed as a render array (basically each menu item is a link within a div wrapper).  Below is example of how a menu item is being constructed:

foreach ($siblings as $sibling) {
  $link = l($sibling-&gt;link_title, $sibling-&gt;link_path);
  $menu_item = array(
    '#type' =&gt; 'container',
    '#attributes' =&gt; array(
      'class' =&gt; array('nav-level0'),
    ),
    'content' =&gt; array(
      '#markup' =&gt; $link,
    ),
  );
  $menu[] = $menu_item;
}
Yes, menu_get_item() will set return an access element that notes whether the current user has access. 

  $siblings = db_select('menu_links', 'ml')
    -&gt;fields('ml')
    -&gt;condition('plid', $target['plid'])
    -&gt;condition('hidden', 0)
    -&gt;orderBy('weight')
    -&gt;execute();
  foreach($siblings as $sibling) {
    $menu_item = menu_get_item($sibling-&gt;link_path);

    if($menu_item['access']) { 
      //Current user has access
    } else { 
      //Current user doesn't has access
    }
  }