It seems that even when there is no navigation menu the navigation block is still rendered, with no content.

I tracked the problem back to the user module, in the user_block function:

      case 1:
        if ($menu = menu_tree()) {
           $block["subject"] = $user->uid ? $user->name : t("Navigation");
           $block["content"] = "<div id=\"menu\">". $menu ."</div>";
        }

The user_block already checks for menu_tree being NULL, But then I looked at menu_tree() in menu.inc, and it seems that if the all the menu_items are hidden, then menu_tree() will return an empty list.

I think I have fixed it, but I do not yet have my CVS account which I applied for. I will post the patch to the development list later.

Here is my changed menu_tree() function, just in case someone wants to go ahead and change it now.

function menu_tree($parent = "") {
  global $_list;
  static $trail;

  if (empty($trail)) {
    $trail = menu_get_trail($_GET["q"]);
  }

  if ($_list[$parent]["children"]) {
    usort($_list[$parent]["children"], "_menu_sort");
    foreach ($_list[$parent]["children"] as $item) {
      /*
      ** Don't render the menu when it is hidden, or when it has no call-back
      ** nor children.  The latter check avoids that useless links are being
      ** rendered.
      */
      if ($_list[$item]["hidden"] == 0 && ($_list[$item]["callback"] || $_list[$item]["children"])) {
        $style = ($_list[$item]["children"] ? (menu_in_active_trail($item)  ? "expanded" : "collapsed") : "leaf");
        $o_list .= "<li class=\"$style\">";
        $o_list .= _render_item($item);
        if (menu_in_active_trail($item)) {
          $o_list .= menu_tree($item);
        }
        $o_list .= "</li>\n";
      }
    }
    if( $o_list != '' )
    {
      $output  = "\n<ul>\n";
      $output .= $o_list;
      $output .= "</ul>\n";
    }
  }

  return $output;
}

Comments

CodeMonkeyX’s picture

One addition. $o_list should be set to NULL ('') at some point before entering the foreach loop.

CodeMonkeyX’s picture

Well I submitted my patch to the devel mailing list. When it is accepted and the cvs is patched I will change this to fixed.

jonbob’s picture

This issue was duplicated by a later bug report and fixed there.