If hs_menu is active, you can't add menu items to a menu that doesn't have any menu items yet, using the menu admin form at admin -> structure -> menus -> list links -> add link .

This is due to the fact that menu_get_names(), called in hs_menu_hierarchical_select_valid_item(), gets the menu names from the menu_links table. The function will be removed in D8 in favour of menu_get_menus(), see http://drupal.org/node/784856.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

firebird’s picture

Status: Active » Needs review
FileSize
486 bytes

Here's a patch that makes hs_menu_hierarchical_select_valid_item() call menu_get_menus() instead.

andypost’s picture

Status: Needs review » Needs work
+++ b/modules/hs_menu.module
@@ -160,7 +160,7 @@ function hs_menu_hierarchical_select_valid_item($item, $params) {
-  $valid = (in_array($parts[0], menu_get_names()));
+  $valid = (array_key_exists($parts[0], menu_get_menus()));

suppose isset() a bit better

$all_menus = menu_get_menus();
$valid = isset($all_menus[$parts[0]]);
firebird’s picture

I think (can't remember, though) that I used array_key_exists for a reason. If $parts[0] is set to NULL, isset() will return FALSE, whereas array_key_exists() will return TRUE.

andypost’s picture

I'm not sure that menu_get_names() returns a keyed array.

But checking for NULL inside array seems useless

Road Kill’s picture

Thanks for the patch Firebird I tried the patch but now I am getting

Notice: Undefined variable: parts in hs_menu_hierarchical_select_valid_item() (line 166 of C:\wamp\www\mysite\sites\all\modules\hierarchical_select\modules\hs_menu.module).

Any ideas anybody

Wim Leers’s picture

Priority: Normal » Minor
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xbery’s picture

This issue is actually still active. Sorry to reopen this but I had to manually patch the hs_menu.module file. Could the patch mentioned in #6 be committed in next release? It works great.

Wim Leers’s picture

It has been committed. No new release has been tagged though.

xbery’s picture

Yep I realised that the moment I posted this comment :-) Though it makes it harder for us who use this great module :-) I really appreciate the work that has been made but issues as serious as this must be fixed when solution is known and agreed to. Just my opinion :-)

(I got really scared when I couldn't save any menu item)

xbery’s picture

Issue summary: View changes

Specified where the adding of menu links doesn't work.