Warning in HierarchyChildrenForm::actions when add child links are empty array

Created on 10 October 2024, 6 months ago

Problem/Motivation

There is a warning in \Drupal\entity_hierarchy\Form\HierarchyChildrenForm::actions, when add children links are empty array

Warning: Trying to access array offset on value of type bool in Drupal\entity_hierarchy\Form\HierarchyChildrenForm->actions() (line 245 of modules/contrib/entity_hierarchy/src/Form/HierarchyChildrenForm.php).

Steps to reproduce

  • Login as a user with reorder entity_hierarchy children permission but doesn't have permission to add children node.
  • Configure the site to display errors and warnings.
  • Visit entity.node.entity_hierarchy_reorder route.
  • Warning message as above will be displayed.

Proposed resolution

Change the condition for $actions['add_child'] to be a link only if the $links have 1 element, otherwise, make it a dropbutton. Dropbutton won't be rendered if the links are empty array, so this won't change the behaviour.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

Code (module)

Created by

🇮🇩Indonesia el7cosmos 🇮🇩 GMT+7

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