Steps to reproduce:
- clean install of drupal
- install 2 languages
- install i18n
- install node hierarchy
- create a node and 'create menu' with node hierarchy option (set a language optional)
- save and note that menu entry is created succesfully
- edit the same node; select "recreate menu"
- save and note the double entry in the menu system
The following ominous message appears (from Drupal_set_message)
* The menu item blaap has been updated with node language.
* The menu item blaap has been added.
* The Page has been updated.
As u can see the menu item is updated first with the node language (whether the node has a language set or not)
After that it adds a new menu item, without the language set
Reproduce the last 2 steps and notice that every time a new link will be created.
In a follow up i will post some additional information.
Comments
Comment #1
dagomar commentedI decided to keep the bug reprot and my speculations apart, hence the new post.
I have been taking some time to look at this and I suspect there is a problem with $node->menu['mid'] not being available. From menu.module starting line 548 I found that a menu item will be created if 'mid' is not set.
from i18n module around line 186 i can conlude that 'mid' is present for the node being updated with the language.
from nodehierarchy menu i found that 'mid' is not present; resulting in menu.module creating the new item.
I have manually set $node->menu['mid'] = 148; // 148 = the mid of my testnode
this seems to make menu.module update the menu item rather than create a new one. I can do everything with the menu, replace it, etc. without more problems.
I am now glancing hopefully at the function at line 880 in nodehierarchy.module (_nodehierarchy_get_menu). I will see if i can get the mid for the node from that function.
Hope i am clear.
PS Related issue: #230978: Issue with i18n on 5.7 - Create Menu option does not assign a language to the menu
Comment #2
ronan commentedthanks for the research, I'll try and get to this as soon as I can.
R
Comment #3
dagomar commentedI seem to have had some success now. My code is kinda scrambled but what i did was use _nodehierarchy_get_menu to return the mid and then set:
inserted on line 847:
this seems to have solved my issues...
Comment #4
ronan commentedThat's fantastic. I'm still not 100% sure what you did, but I'm sure if I use your steps to reproduce this it'll make a lot more sense. I'll try and get a fix in to help anybody else using i18n. Did you change nodehierarchy to fix your issue? If so, do you mind submitting a patch of your changes. That would really help me get this fix out.
Thanks again
R
Comment #5
dagomar commentedhi ronan,
i am not really comfy with making patches, no experience with them whatsoever. I can only write down here what it is i did, perhaps u are able to create a patch.
on line 847 of nodehierarchy.module, i added
$node->menu['mid'] = _nodehierarchy_get_menu( $node->nid );it was after i tried a lot of things. I knew from looking at menu.module that it needs an existing 'mid' in hierarchy.module when it recreates the menu item, otherwise it will create a new menu item. When i would provide a mid by hand, it was working. So i tried the function _nodehierarchy_get_menu which gives back the mid, and voila, it worked. I haven't been able to figure out why mid was not provided by default, or why it is working as expected when i18n is not installed. This doesn't seem to harm anything else so far, so lets pray this is the solution :)
cheers,
Dago
Comment #6
markhalliwellThis issue pertains to the 5.x branch which is no longer supported. If this issue cannot be resolved within two weeks, it will be closed.
Comment #7
markhalliwellComment #8
markhalliwell