Problem/Motivation

Version 7.x-1.14 seems to have broken menu translation, and it is still broken in 7.x-1.15 and in the current dev branch.

Steps to reproduce error:

  1. Fresh install of Drupal 7.53.
  2. Enable module Entity Translation Menu and all required dependencies
  3. At admin/config/regional/language/configure, enable URL languge detection method for both user interface and content. Save.
  4. At admin/structure/menu/manage/main-menu/edit select Translation mode: Translate and Localize. Save.
  5. Enable two additional languages, e.g. Italian and Portuguese
  6. In Structure > Content Types > Basic page: edit > Publishing options, select Multilingual support: Enabled, with field translation, and save.
  7. In Structure > Content Types > Basic page: manage fields > Body: edit, click Enable translation, and save.
  8. Content > Add content > Basic Page
  9. Set language to English, type in a title "TITLE (all)", check 'Provide a menu link' and type in Menu link title "MENU LINK EN". Save.
  10. In Translate tab, click link to add first translation, e.g. Italian
  11. Change the Menu link title to "MENU LINK IT" and save.
  12. Observe that page is displayed in Italian (URL is /it/node/1) and the menu link "MENU LINK IT" is visible.
  13. In Translate tab, click link to add second translation, e.g. Portuguese
  14. Change the Menu link title to "MENU LINK PT" and save.
  15. with i18n version 7.x-1.13: Observe that page is displayed in Portuguese (URL is /pt-pt/node/1) and the menu link "MENU LINK PT" is visible.
  16. with i18n version 7.x-1.14 and 7.x-1.15: Observe that page is displayed in Portuguese (URL is /pt-pt/node/1) but the menu link "MENU LINK EN" is visible. Further, edit the Portuguese translation and observe that the menu link value is filled in as "MENU LINK EN". And at /admin/config/regional/translate/translate set Limit search to: Menu and Filter to see that the String "MENU LINK EN" does not have a Portuguese translation. (If one is supplied by manually translating the string here, then Drupal does use it when displaying Portuguese content.)

Sorry I haven't been able to find out why this has happened.

Proposed resolution

Remaining tasks

  1. Identify cause of problem
  2. Fix code and submit patch
  3. Expand tests to cover this situation

User interface changes

API changes

Data model changes

Original report by [username]

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

martin_q created an issue. See original summary.

joseph.olstad’s picture

Category: Bug report » Support request

There's over 49500 installations of 7.x-1.14 which was released last year in October 2016 and you're the first one to report this issue.

For this reason, I'm quite sure this isn't a bug so I'm reclassifying it as a support request.

Please consult the documentation

You can also consult the readme.txt file for i18n_menu .

joseph.olstad’s picture

Status: Active » Needs review
martin_q’s picture

Issue summary: View changes

Added missing step to reproduce problem.

martin_q’s picture

Like you, I am surprised that I am the first person reporting this, so I have re-read the documentation and the readme as you suggested. I also just walked through the above described steps again (during which I found I'd forgotten to note an essential step without which you can't actually translate a node), first using D7.54 freshly downloaded plus i18n 7.x-1.13 and using Drush to retrieve 7.x-1.0-beta5 of entity_translation. The menu item for the third language of the node is correctly translated. Then I replaced i18n 7.x-1.13 with 7.x-1.14 and repeated steps 8-14, and the menu item for the third language of this second node is not correctly translated.

This is true regardless of whether I use entity_translation_i18n_menu version 7.x-1.0-beta5 or the current 7.x-1.x-dev.

So I guess I do, as you suggest, need support to move on from here, because if
(a) previously demonstrably working behaviour is now demonstrably broken following an i18n version change, and
(b) if there's no way it can be the fault of i18n...
then
- either my workflow is wrong (the brief comment about having to have translated content first, under "Troubleshooting" in the readme, is vague on this point),
- or I'm depending on unintended and therefore unsupported behaviour of either i18n_menu or entity_translation_i18n_menu

In case it is either of the above possibilities, having re-reviewed the documentation and readme files, I am stumped as to what I am doing wrong. As the steps I took are documented above, if someone can review them and point out my mistake I'd be truly grateful.

(By the way, I note that some tests for entity_translation_i18_menu, previously working on i18n 7.x-1.13, now fail on 7.x-1.14 - #2836238: Entity Translation Menu (entity_translation_i18n_menu) compatibility check against the i18n_menu (7.x-1.x-1.14) - though this is a slightly different situation (they only have English and Spanish in their tests, and I'm reporting something that happens with a third language), and it is still an active issue. But it demonstrates that 7.x-1.14 has led to at least one other thing breaking... :) )

joseph.olstad’s picture

Category: Support request » Bug report
Status: Needs review » Needs work

Thanks for your detailed analysis. Should be easy to fix.

Easiest way to debug, clone the i18n repo, replace yours with it.

You already know that the issue is in between 1.13 and 1.14 because it regressed in 1.14

Use git to locate changes to i18n_menu between 2015 1.13 release and 1.14. To find the culprit;

cd i18n;
git log i18n_menu;

This will give you all changes to i18n_menu starting with the latest descending order. Zero in on the changes before November 2016 and 2015

I will have a look myself and see.

If you are good with git you can git checkout before and after suspected regression and pinpoint the exact commit and date, with that we can create a new patch or revert the regressed code change depending on what it is.

I know we did do one change to i18n_menu that gave us a huge performance improvement, it is possible that this also created a problem for trilingual or quadrilingual menu link translations. Keep in mind there's several different ways to use i18n_menu for translation of menu links. There may also be a workaround for this use case but let's start by locating the suspect commit.

joseph.olstad’s picture

http://cgit.drupalcode.org/i18n/log/i18n_menu?qt=grep&q=

There were three commits to i18n_menu October 22, 2016

Have a look at those three.

joseph.olstad’s picture

Title: Menu translation broken in 1.14/15 when editing 2 or more translations » Menu translation broken in 1.14/15 when editing 3 or more translations
joseph.olstad’s picture

Hi @martin_q,

I've created two different patches. I'm fairly confident that at least one of them will work for you. Please tell me which one of these works.

These two patches will revert respectively the two changes made to i18n_menu between 7.x-1.13 release and 7.x-1.14 release

Instructions : restore version 7.x-1.15, then apply one of the patches, repeat your test.
it should work, if it doesn't then apply the second patch. and tell me if that works, at this point I'm 99% sure that it'll work.

If you can tell me which one of these two patches works for you (patch against 7.x-1.15)
then I (or we) can investigate and find the best possible solution moving forward.

joseph.olstad’s picture

Status: Needs work » Needs review

trigger the testbot

joseph.olstad’s picture

try this patch (against 7.x-1.15) first:
https://www.drupal.org/files/issues/revert_c5ed2b268c7_nov13_2015_issueN...
I hope its this one

but if not, then apply the other one (again against 7.x-1.15).
https://www.drupal.org/files/issues/revert_307b54dcdb_oct22_2016_issueNu...

joseph.olstad’s picture

Priority: Normal » Critical

bump up the priority, please provide feedback asap.

martin_q’s picture

Thanks for the tips and the patches. Will be trying them in the next couple of hours and will let you know as soon as I have a result.

martin_q’s picture

Sorry for the delay. Thanks for providing the patches.

I can report:
revert_c5ed2b268c7_nov13_2015_issueNumber2614700-2848806-9.patch - did NOT fix this issue
revert_307b54dcdb_oct22_2016_issueNumber2338735-2848806-9.patch - DID fix this issue

joseph.olstad’s picture

Hi @martin_q , thanks for the feedback,
followup work in
#2338735: hook_menu_link_alter() should set $item['i18n_tsid']

joseph.olstad’s picture

joseph.olstad’s picture

joseph.olstad’s picture

@martin_q , what version of php are you using when you observed this issue ?

If you can provide this information it will help me better pinpoint a solution.

joseph.olstad’s picture

Alternatively, this might be a more desirable solution that will work best for everyone.

TODO: could probably static cache the count variable, increase performance, as that list languages call will get called too many times unnecessarily otherwise. Potentially improve performance of this.

Status: Needs review » Needs work

The last submitted patch, 19: regression_fix-2848806-18.patch, failed testing.

joseph.olstad’s picture

re-queueing again, looks like a testbot hiccup unrelated to patch

joseph.olstad’s picture

Status: Needs work » Needs review

Latest patch needs review

joseph.olstad’s picture

I'm sure there is a better solution, feel free to post one

martin_q’s picture

I observed the problem on my machine, running PHP 5.5.32.
My colleagues and our testbot also observed the problem with PHP 5.6.30 and 7.0.13, respectively.

The most recent patch looks like it would fix the problem reliably, but is perhaps slightly overcompensating. It's not the *presence* of three or more languages on a site that causes the problem, but the fact that one is saving a translation in a third language. That said, I'm not sure how easy it is to find out the latter... I'm sorry I'm not able, at the moment, to contribute more time to helping investigate/fix this.

joseph.olstad’s picture

patch 18 has not been tested.

patch 9 could use more testing and analysis.

Stevel’s picture

The patch in #19 does not solve the issues for entity translation. revert_307b54dcdb_oct22_2016_issueNumber2338735-2848806-9.patch from #9 does seem to work.

joseph.olstad’s picture

ok, so we should revert this then.

  • Stevel authored f972b65 on 7.x-1.x
    Issue #2848806 by martin_q, Stevel: revert commit 307b54dcdb from oct22...
joseph.olstad’s picture

Status: Needs review » Fixed

fixed

Status: Fixed » Closed (fixed)

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