@FeyP reported the original (related) issue which happens in core but the problematic portion of the code is identical in token and the issue also happen here. I've ported the patch here based on his work in the related issue.
When changing the language of an existing node to a pseudo language I get the following error:
InvalidArgumentException</em>: Invalid translation language (und) specified. in <em class="placeholder">Drupal\Core\Entity\ContentEntityBase->addTranslation()</em> (line <em class="placeholder">947</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/ContentEntityBase.php</em>). <pre class="backtrace">token_node_menu_link_submit('node', Object, Array, Object)
call_user_func_array('token_node_menu_link_submit', Array) (Line: 299)
...Here is the introduction of the original report:
Changing the language of a translatable node with a translatable menu link from a "real" language (e.g. en) to a "pseudo" language (und or zxx) will result in an invalid argument exception: Invalid translation language (und) specified. or Invalid translation language (zxx) specified. respectively.
Issue fork token-2986581
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
idflood commentedHere is the patch based on https://www.drupal.org/project/drupal/issues/2904899#comment-12243129
Comment #3
idflood commentedComment #4
berdirNice catch. Can we extend \Drupal\token\Tests\TokenMenuTest so it covers this scenario as well?
Comment #5
malte.koelle commentedI created a test similar to the test in the issue #2904899.
First I create a node with the Language English and try to access the node.
Then I create a menu link and change the language to "not specified" and again try to access the page.
I would be glad if someone can review my test.
Comment #7
malte.koelle commentedI moved the setUp part directly to my test method, since it creates a node with a specific id and it cannot do it twice.
Hopefully the test works now. :)
Comment #8
malte.koelle commentedComment #9
anybodyJust ran into this. Adding some similar issues in core and contrib.
Comment #10
anybodyThis needs a reroll against latest version.
Comment #12
anybody@Berdir: Would you like to review this?
I rerolled #7 as MR!31 without any additional changes.
Removing "Needs tests" as tests were added in #7. Credits to malte.koelle! :)
Comment #13
anybodyHere's the diff from MR!31 if anyone needs it locked. Should also work with 8.x-1.10+!
RTBC+1 from my side, we were running into this issue and with the patch applied it's fixed!
Comment #14
socialnicheguru commentedconflicts with #3168340: Node menu link translation breaks content translation
Comment #15
idflood commentedHere is a reroll of patch #13. I can push a new branch with just this if needed.