While I was working on the port of Menu Admin per Menu to Drupal 7, I found this bug:
How to reproduce the bug?
1. Create a content type called Page (for instance) and check only Main menu as Available menus.
2. Add a new Page content and provide a menu link. You will notice that Parent item only list Main menu items as options, which is the expected behavior.
3. Navigate to admin/structure/menu/manage/main-menu to list Main menu items and edit the link you just added at 2.
4. Look at the Parent item select box: it allows all the existing menu items as parent when it should only allow Main menu items.
I mark this as critical as it is a security issue.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | menu.test.patch | 2.58 KB | anrikun |
| #23 | menu.patch | 3.71 KB | anrikun |
| #20 | menu.patch | 3.71 KB | anrikun |
| #17 | menu.patch | 2.04 KB | anrikun |
| #16 | menu.admin_.inc_.patch.txt | 1.13 KB | anrikun |
Comments
Comment #1
anrikun commentedI just noticed that where is a @todo about this in menu.module
Is someone already working on it?
Comment #2
montesq commentedHello anrikun,
This is the normal behaviour.
In the content-type form, if you select the option "provide a menu link", it just means that when you create a new content (for instance page), you are able to add a link in the selected menu.
It doesn't mean that nobody can put a link in another menu to this content.
Moreover, when you use the administrator account, you don't see this, but to proceed the first step you need the "create Page content" permission, whereas to accomplish the step 3, you need the permission "Administer menus and menu items"
Comment #3
tim.plunkettComment #4
anrikun commentedAfter reading your explanation, I think you are right.
Actually, this check has to be performed by Menu Admin per Menu and not by Core.
Thank you for your answer!
Comment #5
anrikun commentedReopening this as I really think there is something strange here.
After the steps written in my first post, do the following:
5. From the Parent item select box, choose a parent item of a menu different from Main menu, let's say Management for instance.
6. Edit again the Page content added at 2.
7. Look at the Parent item select box: the selected parent item is now <Main Menu>!
Imagine that you just wanted to change the title of the page and you that you save. The menu item pointing to the page will be moved from Management to Main Menu and you might not even have noticed it!
This kind of conflict can definitely not be considered as a normal behaviour.
A possible solution is to disable the Parent item field in the node edit form when the existing menu link belongs to a unallowed menu for the content type.
I think that it is what the @todo at #1 refers to.
Comment #6
anrikun commentedComment #7
anrikun commentedAnother (preferred) possible solution would be to add an extra validation to the menu_edit_item form:
if the Path points to a node which content type does not allow the selected Parent item, display an error about the selectedParent item.
Comment #8
tim.plunkettNot reproducible in Core. The steps to reproduce aren't even possible without the Menu Admin per Menu module.
Comment #9
anrikun commentedAre you kidding?
Why are you moving this to the Menu Admin per Menu module which is not even ported to Drupal 7 yet?
The issue I'm talking about is in Drupal 7, not Drupal 6.
Please follow the steps again or at least let someone else do it and give his option too, before deciding to close or move this issue this way.
By the way, there is another bug here:
#955848: When editing an existing node with a link, the link itself is listed in "Parent item": menu_parent_options needs some rewriting
I'm currently working on this issue to provide a patch so please do not close it again.
Comment #10
montesq commented@tim.plunkett
Yes that is reproducible in core...
Let me sum up the steps:
1. Create a content type called Page (for instance) and check only Main menu as Available menus.
2. Add a new Page content and provide a menu link. You will notice that Parent item only list Main menu items as options, which is the expected behavior.
3. Navigate to admin/structure/menu/manage/main-menu to list Main menu items and edit the link you just added at 2.
4. Change the parent link for "management"
=>you can check that the link has been removed from main menu and added in the menu management = normal behaviour for me
5. Edit the node and without changing anything click on "save"
=> the link in "main menu" appears again and disappears from the management menu: I agree with anrikun that this behaviour is quite surprising but I very embarrassed for the solution...
Comment #11
tim.plunkettMy apologies, I must have gotten lost between the OP and the steps in #5.
Comment #12
anrikun commentedHere is a patch that implements the solution at #7.
Hope it passes validation.
Comment #14
anrikun commentedWell, as I am new to SimpleTest, I need help to figure out why the patch failed testing.
AFAIK it seems to work in real testing.
Comment #16
anrikun commentedHere is an updated patch: I have added a missing ^ in the preg_match.
This patch will not pass current test as menu.test itself should be updated to handle the extra validation added by the patch.
That is why I have added the .txt extension to the file name.
Please review it.
Comment #17
anrikun commentedUpdated patch with test.menu
Comment #18
anrikun commentedImagine that you want to let a user administer menus and menu items but not content types.
You give this user the "Administer menus and menu items" permission, but not the "Administer content types" permission.
Doing so, you expect that this user will not be allowed to move a node menu link to a menu that is not set as available for this node's content type.
That is why I think this a security issue, thus marking this as critical again.
Comment #19
catchThe menu drop-down restriction is an interface setting for usability, it's not a permission, so this isn't a security issue. It is however an annoying bug so leaving at 'major'. I have a feeling there's an older issue about this, couldn't find it, but while looking I found #949712: When Editing a Basic Page that has a Menu Item on a custom menu, it defaults to being on Main Menu - and deletes a menu item. which was duplicate.
It would be good to update the test so it actually fails without the patch.
Comment #20
anrikun commentedHere is a new patch with menu.test updated to fail without the patch.
Comment #21
anrikun commentedNow the patch for menu.test alone.
It should fail 4 times.
Comment #23
anrikun commentedThe previous patch failed as expected.
Now let's put back the full patch.
Please review and commit it.
Comment #24
anrikun commentedChanging to "Unassign" as I have finished working on this issue.
Comment #25
anrikun commentedChanging title to better describe the issue.
Comment #26
lyd commentedI love Drupal 7 so far but this problem is impossible to live with.
As main administrator, I last updated Drupal 7 core on Jan 29th (drupal-7.x-dev)
Every time I update a single word in the body and save, the page disappears from my menu and appears in the secondary links menu.
The only way to move it back is via admin/structure/menu.
This creates endless hassle.
Is there something I do not understand?
Comment #27
lyd commentedApologies. I found my answer here:
http://drupal.org/node/957784
#4 Posted by marcingy on November 12, 2010 at 10:46pm
Priority: major » normal
No it doesn't the issue is caused by the fact that you have created a new menu and then have not defined this menu as being available for the content type under admin/structure/types/manage/xxx. This results in the menu item being associated with main menu as that is the only menu option that has been available.
I simply had not made all relevant menus available in the content type.
Comment #28
jastraat commentedsubscribe
Comment #29
zilverdistel commentedsubscribe
Comment #30
anrikun commented@jastraat, @zilverdistel:
Did you review the patch?
Comment #31
jastraat commented@anrikun
Just tested the patch from #23 against latest -dev
When trying to change a page (only allowed in main menu) to have the management menu as its parent through the menu administration page, get a notice: "The Management menu cannot contain links to the path 'node/12'."
While this seems better than the original behavior, I still think it would be more user-friendly for non-options not to appear in the parent select in the first place.
Comment #32
anrikun commentedUnfortunately, this is not that easy: you cannot tell what parent option is allowed or not before the user actually submits a path.
We could imagine some Ajax feature that would dynamically rebuild the parent options based on the path the user has just entered, but that would be an extra feature.
Here the issue is just about fixing the missing validation bug that leads to unallowed modifications.
Reading that, do you think the patch does the job?
Comment #33
jastraat commentedThe patch prevents a node from being put into a disallowed menu, so it fixes the validation problem.
Comment #34
anrikun commentedI suggest you mark this issue as RTBC then.
Comment #35
bfroehle commentedLet me reiterate webchick's comment from another issue (#955848-23: When editing an existing node with a link, the link itself is listed in "Parent item": menu_parent_options needs some rewriting) -- I'm not sure this level of coupling between menu and node is going to fly.
Also, the usability of the patch needs some work.
Also, the error message is totally obscure. "The Development menu cannot contain links to the path 'node/9'."
It would at least be a little more transparent if it read something like
Lastly, is this even a bug? As an admin, I might want to manually move certain pages to certain menus, but then not make it easy for a generic user to do so on the node form.
Powered by Dreditor.
Comment #37
anrikun commentedThis no longer applies as latest 7.x behavior is now OK:
When editing a node that has a menu link in an unallowed menu, the "Menu settings" fiedset displays "Provide a menu link" as unchecked, thus hiding the menu link because it is in an unallowed menu.