Fix: Warning: foreach() argument must be of type array|object, null given in menu_link_attributes_menu_link_content_form_entity_builder()

Problem/Motivation

Core version: 10.1.4
Module version: 8.x-1.3

There is an issue Warning: foreach() argument must be of type array|object, null given in menu_link_attributes_menu_link_content_form_entity_builder() (line 147 of modules/contrib/menu_link_attributes/menu_link_attributes.module). when adding a new menu item without providing any attribute value

Steps to reproduce

1. Create a new menu item for any menu and do not provide any attribute value for the item
2. Click the save button
3. There will be shown a warning message: Warning: foreach() argument must be of type array|object, null given in menu_link_attributes_menu_link_content_form_entity_builder() (line 147 of modules/contrib/menu_link_attributes/menu_link_attributes.module).

Proposed resolution

1. Prepare a proper patch in order to fix the issue
2. Prepare an MR for review

Remaining tasks

Write the fix and do the mentioned above.

User interface changes

No.

API changes

No.

Data model changes

No.

Edited by drupalbot
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information