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.

CommentFileSizeAuthor
#2 check_translation.patch957 bytesgyd
check_translation.patch1.53 KBgyd

Comments

gyd created an issue. See original summary.

gyd’s picture

StatusFileSize
new957 bytes

Fixed patch also including changes for 3475233

  • a0ba7aa7 committed on 8.x-1.x
    Issue #3475243
    
    Check if node translation exist before loading it
    
rutiolma’s picture

Status: Active » Fixed

Thanks! I'll make a release with this fix

Status: Fixed » Closed (fixed)

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