Menu link translations can not be cteated

Created on 8 October 2024, about 1 month ago

Problem/Motivation

In case when menu_link_attributes providing the class attribute it's not possible to save menu link translation.

Steps to reproduce

1. Ensure that you have class attribute added to the configuratrion at /admin/config/menu_link_attributes/config
2. Create a menu link in English language, you can keep the cvalue for class attribute empty
3. Click on add a translation and try to save it, without any changes
4. You should be able to see the error: "Non-translatable fields can only be changed when updating the original language."

After deeper investigation I found that NestedArray::mergeDeep producing multiple array keys when saving translation and as a result EntityUntranslatableFieldsConstraintValidator throws validation error.

$existing_options = {array[1]} 
 attributes = {array[1]} 
  class = {array[1]} 
   0 = ""
$menu_link_options = {array[1]} 
 attributes = {array[3]} 
  class = {array[1]} 
   0 = ""
  data-separator = {int} 0
  display-shop = {int} 0
NestedArray::mergeDeep($existing_options, $menu_link_options)

attributes = {array[3]} 
 class = {array[2]} 
  0 = ""
  1 = ""
 data-separator = {int} 0
 display-shop = {int} 0

Proposed resolution

Replace NestedArray::mergeDeep($existing_options, $menu_link_options) with NestedArray::mergeDeepArray([$existing_options, $menu_link_options], TRUE) to preserve integer keys instead of appending them.

πŸ› Bug report
Status

Active

Version

1.5

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine cmd87

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024