hi, i have tested a lot, but i can't figure out whats going on.

i18n 7.x-1.8
entity_translation 7.x-1.0-beta2+33-dev
drupal 7.22

the case, as follows:
* i use the main menu with translated links.
* the default language is now set to german (after some links/nodes allready were created).
* i try to create a translation of a node, with, or without 'create menu link' checked and the corresponding english menu link is deleted.
* no other language is deleted and this happens if the english link is the original language, as also if not..

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

carligraph’s picture

i tried now to completely recreate the menu and can confirm, that it always deletes the original language (ie first created).

carligraph’s picture

another weird thing is, that the source language changes to the last updated language, when editing the menu-link-translation...

bforchhammer’s picture

Status: Active » Postponed (maintainer needs more info)

According to our tests this should be working. If you have a look at EntityTranslationMenuTranslationTestCase::testMenuLocalization, you'll see that we create a page in English with a Spanish translation and check that both menu links exist afterwards. Editing is checked as well, and doesn't affect the respective other language in our test case. (All tests are passing.)

Are you testing on a clean install, or could it be another module interfering?

carligraph’s picture

you are right, it's not a fresh install - it's a real-life test ;)
i will try it soon on a fresh install and report..

carligraph’s picture

Status: Active » Postponed (maintainer needs more info)

now i tried it with a completely fresh install and the same thing happens again, when translating into a third language..

it always deletes the menu entry from the original language.
it's the same when using the main menu, as using a seperate menu for each language.

bforchhammer’s picture

Status: Postponed (maintainer needs more info) » Active

now i tried it with a completely fresh install and the same thing happens again, when translating into a third language..

Okay, so does this only happen with a third language? Can you check whether this is related to the current interface language at all? (That is, does it make a difference whether your add a translation with the form being in English vs. the form being in German?)

carligraph’s picture

yes, it only happens when using a third language.
no, it doesn't depend on which language-interface i am, while submiting the form.

while testing around i recognized that it only deletes links at the first level from which it contains child-links.
(this happens when translating the article, even if i dont check the box to add a menu link)

for better understanding, an example:

main menu
    |
    -- home (node 1)
    |
    -- link1 (node 2)
        |
         -- sublink1 (node 3)
             |
              -- sublink2 (node 4)
    |
    -- link2 (node5)

when translating node 2, it deletes link1 here, when translating node 3, it deletes sublink1. better said: it changes the link from the original language to the translated language.

bforchhammer’s picture

Status: Postponed (maintainer needs more info) » Active

when translating node 2, it deletes link1 here, when translating node 3, it deletes sublink1.

So it always deletes the menu link which is associated with the node that you're currently translating. That kindof makes sense.

I will have to test this out myself later. If you could provide a step-by-step description of how to reproduce the behavior from a freshly installed version, that would be helpful. (Including configuration steps taken etc.)

carligraph’s picture

step-by-step description:

  • create new site (with aegir)
  • activate following modules:
    • Entity Translation Menu (7.x-1.0-beta2+33-dev + all dependencies)
    • Localization update (7.x-1.0-beta3)
    • Title (7.x-1.0-alpha7)
  • enable two other languages
  • configured language-detection by url (conten+interface)
  • configured main menu to Translate and Localize.
  • disabled language fallback and content translation links hidden
  • content type article field translation enabled
  • title replaced with a field instance
  • create an article with menu-link link1
  • create 2nd article with menu-link link1--sublink1
  • create 3rd article with menu-link link1--sublink1--sublink2
  • translate 2nd article to 2nd language with menu-link link1--sublink1 for 2nd language only
  • translate 2nd article to 3rd language with menu-link link1--sublink1 for 3nd language only

now link1--sublink1 from 1st language changed to the third language. link1--sublink1--sublink2 is still there but has also moved with link1--sublink1 but not changed the language.

edit: maybe i made a mistake here, so not confirmed (the second time it was working):
meanwhile i did one more fresh install and the case appears allready, when translating the 3rd article (and link1--sublink1--sublink2) to the second language (German, English=orig). also the translated article/title (the only translatable field by now) disappears (switches to the translated language) now.

carligraph’s picture

here are two pictures from the menu structure before and after translating the 2nd article to the 3rd language.

carligraph’s picture

it seems, it has to do something with this warning/function:

Warning: explode() expects parameter 2 to be string, array given in menu_node_submit() (Zeile 722 von drupal-7.22/modules/menu/menu.module).
Warning: explode() expects parameter 2 to be string, array given in entity_translation_i18n_menu_item_tset_prepare() (Zeile 336 von drupal-7.22/sites/all/modules/entity_translation/entity_translation_i18n_menu/entity_translation_i18n_menu.module).

changing line 336 to

list($entity->menu['menu_name'], $entity->menu['plid']) = explode(':', $entity->menu['parent'][0]);

seems to work but only, when editing/translating an existing article and not when adding a new one and the warning explode() expects parameter 2 to be string in menu.module persists..

bforchhammer’s picture

First off, thanks for your detailed steps to reproduce. I think I now understand what this issue is about :)

So, when you tick the "Menu link enabled only for the Deutsch language" checkbox on a node, it switches the mode of translation from "localization" to "translation sets" for menu items. This means that instead of having just one (localized) menu item on all languages, you will have multiple menu items for different languages.

Whenever you tick this checkbox for the first time on a node (or on one of its translations), it will take the existing menu item, and convert it to the current language. This means, it won't be shown for other languages anymore, thereby appearing to delete menu items for other (e.g. the original) languages.

The obvious "quick fix": If you want separate menu items for different languages (which I assume you do according to your example), tick the checkbox already when you create the original node; then you won't loose it when you create new ones for other languages. Alternatively, go back afterwards and recreate your missing menu items. They should not go missing again afterwards.

Does this explain your situation?

The notices look like they might be related to #1992588: PHP Notices on node page. If you can, please see if the patch over there fixes your notices.

Also, I guess we could turn this issue into a feature request: we can probably try to handle the switch from the localization mode to translation sets better, i.e. try to create additional menu items when switching from localization to translation sets.

carligraph’s picture

The obvious "quick fix": If you want separate menu items for different languages (which I assume you do according to your example), tick the checkbox already when you create the original node; then you won't loose it when you create new ones for other languages. Alternatively, go back afterwards and recreate your missing menu items. They should not go missing again afterwards.

if i activate that checkbox on a new node the same problem appears again: when translating into the 3rd language and the menu-link has child-links the original language will be changed into the 3rd language. so it doesn't fix the problem for me.

the warning from #11 was only produced, when using hierarchical select menu (7.x-3.0-alpha5). ok, thats maybe another issue, but with this module it doesn't even work to translate/add a menu-link within the node-form.

because of that i think it has something todo with the hierarchy of the menu and tried to change that line in entity_translation_i18n_menu.module and, voila, it was working to add a translation of the menu-link and also the original language wasn't overwritten anymore. the only thing: i doesn't work to add a menu-link, when creating a new node, it only works when editing a firstly created node.

carligraph’s picture

bforchhammer’s picture

Status: Active » Needs review
FileSize
2.86 KB
1.46 KB

Hm, this took me a while to reproduce, but I think I was finally able to do so... I think this only happens when using translation sets and adding a second translation. Let's see what the test bot thinks.

Status: Needs review » Needs work

The last submitted patch, et-tset-bug-1982140-15.patch, failed testing.

bforchhammer’s picture

Status: Needs work » Needs review
FileSize
3.36 KB
1.95 KB

Hm, #15 failed for the wrong reason; let's try this again... The test-only patch should fail, because it tries to reproduce the faulty behavior described above. The other one should fix it and pass.

bforchhammer’s picture

@carligraph: Can you download and apply et-tset-bug-1982140-17.patch, and check whether that fixes your problem?

carligraph’s picture

thanks for the patch - it works!

i don't know, if it has something to do with this issue, but the warning

Warning: explode() expects parameter 2 to be string, array given in menu_node_submit() (Zeile 722 von /var/aegir/platforms/drupal-7.22/modules/menu/menu.module).
Warning: explode() expects parameter 2 to be string, array given in entity_translation_i18n_menu_item_tset_prepare() (Zeile 337 von /var/aegir/platforms/drupal-7.22/sites/i18n.ivi.oo0.at/modules/entity_translation/entity_translation_i18n_menu/entity_translation_i18n_menu.module).

still exists when using hierarchical select menu and no menu-link is created with that.

bforchhammer’s picture

Status: Needs review » Reviewed & tested by the community

Cool, then I'll commit #17 soon.

The hierarchical select warning looks unrelated. It seems to appear because HS replaces the "parent menu item" form element and thereby changes the expected format of it's value; Core and ET assume that it's a string, HS changes it into an array. I think this needs to be fixed in the HS module; if not, it should go into a new issue.

bforchhammer’s picture

Title: translation of node deletes menu entry of other language » Menu item is deleted when adding a third translation
Status: Reviewed & tested by the community » Fixed

Committed and pushed #17.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

updated text to correct entity_translation version

  • Commit ba653e1 on 7.x-1.x, factory, et-fc, revisions by bforchhammer:
    Issue #1982140 by bforchhammer | carligraph: Fixed Menu item is deleted...

  • Commit ba653e1 on 7.x-1.x, factory, et-fc, revisions, workbench by bforchhammer:
    Issue #1982140 by bforchhammer | carligraph: Fixed Menu item is deleted...