Hi great Drupal Community & Developers,

I discovered a very anoying bug.

Issue in short:
Add a new menu with menu-name of 27 charakters lenght.
Works, correct check.
Now try to delete or rename that menu with 27 charakters.
Doesn't work, because wrong check.
Error message: "The menu name can't be longer than 27 characters."

=> You can create but can't delete a menu with more than 22 charakters anymore.

Issue in long with example:
(all with standard theme)
click to "structure" -> "menus" -> "add menus":
menu name: "abcdefghijklmnopqrstuvwxyza" (27 characters)
title: "test"
-> "save"
works.

click to "menus" -> "test" -> "edit menu"-> "delete":
won't work, message "The menu name can't be longer than 27 characters." appears.

create a menu with "abcdefghijklmnopqrstuv" (22 characters)
works.
delete it.
works.

My guess:
If you edit a menu, you will find in the browser address bar:
"yourdomain.com/admin/build/menu-customize/menu-abcdefghijklmnopqrstuvwxyza/edit"
Drupal seems to handle the menu-name as "menu-{yourMenuName}"
And it seems as drupal would check the number of charakters with this "menu-" prefix. (but not when creating it)

I hope you can understand what I want to describe - otherwise please ask.

I would be very happy if someone can fix that bug soon because it shouln't be very complicated and is really annoying if can't delete a menu anymore.

Thanks a lot.

Kev

PS: My drupal is german, so I translated all terms from german to english. Maybe they are originally a little bit different.

Comments

drupalok’s picture

same here!!! please help!

cwgordon7’s picture

Title: Can't delete menu because of inconsistent length check (27 chars and 22 charakters) » Can't delete menu because of inconsistent length check (27 chars and 22 characters)
Version: 6.10 » 7.x-dev
Issue tags: +Novice

This is still a problem in Drupal 7 and should be addressed there first before being backported to Drupal 6.

The problem is that in the function menu_edit_menu_validate() in modules/menu/menu.admin.inc, the menu name length should not be checked against MENU_MAX_MENU_NAME_LENGTH_UI if $form['#insert'] is not TRUE; the value of MENU_MAX_MENU_NAME_LENGTH_UI is 27 because we prefix 'menu-' (5 characters) to it and the maximum number of characters the database can store is 32. However, if we're not creating a new menu, we are not going to prefix the menu name with 'menu-' again, so we should add 5 to the check to account for the already-prefixed 'menu-'.

I'm tagging this "novice" to indicate that this issue is something that can be tackled by someone just starting contributing to Drupal, but I'm willing to write a patch myself if no one gets to this.

BruceBGordon’s picture

Assigned: Unassigned » BruceBGordon

Saving the world one novice patch at a time.

jbomb’s picture

Assigned: BruceBGordon » jbomb

I'll give it a go.

jbomb’s picture

@BruceBGordon sorry about that. it's all yours.

BruceBGordon’s picture

Assigned: jbomb » BruceBGordon
StatusFileSize
new2.31 KB
BruceBGordon’s picture

Status: Active » Needs review
BruceBGordon’s picture

Made Patch. Updated the test to have items be MENU_MAX_MENU_NAME_LENGTH_UI + prefix long (so they will in fact be 32 characters long). Removed redundant length check because the form validation in function menu_edit_menu does a #maxsize check against MENU_MAX_MENU_NAME_LENGTH_UI.

David_Rothstein’s picture

Is this a duplicate of #292790: Menu machine-name validation error (The menu name can't be longer than 27 characters)? I didn't look closely, but it seems like it might be.

mr.baileys’s picture

Status: Needs review » Closed (duplicate)

Yes, this is a duplicate of #292790: Menu machine-name validation error (The menu name can't be longer than 27 characters). Same approach to fix this has been taken in both issues, but other issue is older and includes the required tests for this scenario, so marking this duplicate.

@BruceBGordon: thanks for your work on this (your patch is correct), sorry to have to mark this a duplicate :(

Onehorse’s picture

I was having this problem...I applied the patch indicated at #31 on the thread at http://drupal.org/node/292790.

This has cleared the problem.

I have no explanation, BUT I thought I should note that one of the menu names I was originally trying to delete was "Contact Menu" which was no where near 27 chars OR 22 chars.