Error when menu link options is null

Created on 27 March 2025, about 1 month ago

Problem/Motivation

We hide the fontawesome fields on the menu link content add form for some of our users.
When they submit the form, it fails with this error:

TypeError:
array_merge(): Argument #1 must be of type array, null given

  at modules/contrib/fontawesome_menu_icons/fontawesome_menu_icons.module:131
  at array_merge(null, array('fa_icon' => '', 'fa_icon_prefix' => 'fa', 'fa_icon_tag' => 'i', 'fa_icon_appearance' => 'before'))
     (modules/contrib/fontawesome_menu_icons/fontawesome_menu_icons.module:131)

This happens because $menu_link->link->first()->options is NULL.

Steps to reproduce

Add this kind of hook:

function foo_form_menu_link_content_form_alter(&$form) : void {
 $form['fa_icon']['#access'] = FALSE;
}

Then try to create a menu link.

Proposed resolution

Check if $menu_link_options is NULL before using it.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇫🇷France prudloff Lille

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