When you follow a specific workflow of creating nodes with translated menu items attached, you can end up in a situation where the node edit form for the translation can't find the associate menu item.

Steps reproduce:

Environment:
1) Have Drupal with entity translation and i18n.
2) Install the standard profile, enable entity_translation_i18n_menu.
3) Add second language, update a node type to use field translation, give that node type a field that's translated
4) Update the Main menu to be "Translate and Localize. Menu items with language will allow translations. Menu items without language will be localized."

Error Situation:
1) Create a new node with a menu item.
2) Edit that node, check the "Menu link enabled only for the @source language" checkbox.
3) Add a translation, in the translation, create a menu item. Translation and menu item are correctly created on save.
4) Edit the translation, the menu link is missing from the node form. Added a new menu item, creates a new menu item, but the edit form will still not be able to see any associated menu items.

Working Situation:
1) Create a new node with a menu item.
2) Add a translation, in the translation, create a menu item, and check the "Menu link enabled only for the @translation language" box. Translation and menu item are correctly created on saved.
3) The edit pages in both language have the correct menu items. Everything works.

Because of the complexity reproducing this, I've attached a "drush arb" of a vanilla site in the error state.

The node type "Basic Page" is the translated content.
The content "test 1" (with menu items "test 1 en" and "test 1 fr") shows content in the working state.
The content "test 2" (with menu items "test 2 en" and "test 2 fr") shows content in the broken state.

CommentFileSizeAuthor
dtest.20131101_074743.tar_.gz3.41 MBspotzero
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

spotzero’s picture

This issue is actually related: #1822116: error with menu attributes

The menu_attributes module freaks out a little in the error state since the menu isn't correctly attached to the node on the node edit form.

spotzero’s picture

Looks like i18n_tsid doesn't get correctly on menu items in the error state. I guess the problem is on save?

bforchhammer’s picture

Sounds like this may be an edge case which we forgot to consider. If I understand correctly, this only happens when you save a node with "Menu link enabled only for the @source language" and there is no translation yet, right?

I think most other cases are already covered by our tests (see EntityTranslationMenuTranslationTestCase::testMenuTranslation()), so we should start by adding this error case to our tests and then we can work on fixing it... My guess is that the problem lies somewhere in entity_translation_i18n_menu_node_presave() or a subsequent method.