Undefined array key 1 in menu_link_weight_node_form_validate()

Created on 23 April 2025, 8 days ago

Problem/Motivation

I am getting the following error which seems to originate from an incompatibility with the Client-side Hierarchical Select module, but can happen also with other modules that might alter forms.

Warning: Undefined array key 1 in ./modules/contrib/menu_link_weight/menu_link_weight.node.inc on line 210

We are making the assumption that under all possible circumstances if a form contains the $form['menu']['link']['menu_parent'] sequence of keys that this is contains the data put there by the core Menu module and has not been altered by other modules. It is not guaranteed that the value of this form element is always as expected.

The error occurs because we are splitting the form element value on the ":" character without checking that this character is present.

Proposed resolution

Put in a simple check if the value contains ":" before continuing. A similar fix has already been applied to menu_link_weight_node_element_process(). We need this fix also in menu_link_weight_node_form_validate().

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇬Bulgaria pfrenssen Sofia

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

Comments & Activities

Production build 0.71.5 2024