Problem/Motivation
_menu_link_sync_get_link_for_target_language function do not check if the node have the translation before getting it.
This is a problem during the execution of “_menu_link_sync_get_most_popular_menu_among_siblings” where this function is used to find the most popular menu for the current language based on the source translation. The result is that the destination language is loaded even if it doesn't exist.
Steps to reproduce
- Create a node in one language, place it at the root of a menu.
- Create a other node in the same language, place it at the root of a menu.
- For the second node, create a translation in another language and sync the menu item.
The following error is displayed:
InvalidArgumentException: Invalid translation language (__TRANSLATION_LANGCODE_) specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation() (line 903 of docroot/core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Proposed resolution
Check if translation exists before loading it.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | check_translation.patch | 957 bytes | gyd |
Comments
Comment #2
gyd commentedFixed patch also including changes for 3475233
Comment #4
rutiolmaThanks! I'll make a release with this fix