Warnings when importing menus using module

Created on 9 February 2023, over 1 year ago
Updated 28 July 2023, 11 months ago

Problem/Motivation

When trying to import a few straight forward menus in D9 under PHP 8.1, the code throws warnings in EntityLoadHelper.php on line 311 - it is not checking for the presence of the array key before trying to return it.

Steps to reproduce

1. Attempt to import the following type of yaml file:

- entity: menu
id: 'main-demo'
label: 'Main menu'
description: 'Demo main menu'
- entity: menu
id: 'footer-demo'
label: 'Footer menu'
description: 'Demo footer menu'

The import will throw a batch of errors of the following:

[warning] Undefined array key "menu" EntityLoadHelper.php:311

Proposed resolution

Change the code in the method getEntityFields:

protected function getEntityFields($entity_type) {
$field_map = $this->getEntityFieldManager()->getFieldMap();
if (isset($field_map[$entity_type])) {
return $field_map[$entity_type];
}
return null;
}

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia matthew.hallsworth.dpc

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

Comments & Activities

Production build 0.69.0 2024