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.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | bug_399070_menu_inconsistent_length_check.patch | 2.31 KB | BruceBGordon |
Comments
Comment #1
drupalok commentedsame here!!! please help!
Comment #2
cwgordon7 commentedThis 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.
Comment #3
BruceBGordon commentedSaving the world one novice patch at a time.
Comment #4
jbomb commentedI'll give it a go.
Comment #5
jbomb commented@BruceBGordon sorry about that. it's all yours.
Comment #6
BruceBGordon commentedComment #7
BruceBGordon commentedComment #8
BruceBGordon commentedMade 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.
Comment #9
David_Rothstein commentedIs 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.
Comment #10
mr.baileysYes, 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 :(
Comment #11
Onehorse commentedI 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.