Errors and warnings when creating new taxonomy and managing display in Display Suite module when config is empty

Created on 8 September 2024, 8 months ago

Problem/Motivation

When creating a new taxonomy term and attempting to manage the display using the Display Suite (ds) module, users encounter the following error and warning:
Error:

The website encountered an unexpected error. Try again later.
Error: Call to a member function label() on null in _ds_field_ui_table_layouts() (line 903 of modules/contrib/ds/includes/field_ui.inc).

Warning:

Warning: Undefined array key "mode" in _ds_field_ui_table_layouts() (line 898 of modules/contrib/ds/includes/field_ui.inc).

The error occurs when the $row array in the code is expected to have certain keys (like 'mode' and 'targetEntityType') but these keys are missing due to empty configuration.

Steps to reproduce

  1. Install and enable the Display Suite (ds) module.
  2. Create a new taxonomy vocabulary.
  3. Try to manage the display settings for the new taxonomy term (e.g., attempt to configure fields layout using ds).
  4. The error and warning will be triggered because the configuration is empty or incomplete.

Proposed resolution

  • Add checks to ensure that required keys such as 'mode', 'targetEntityType', and 'bundle' exist in the $row array before accessing them.
  • If these keys are missing, handle it gracefully by skipping or defaulting to appropriate values, avoiding the undefined index warning and null method calls.

Remaining tasks

Write tests to ensure the error no longer occurs with empty or missing configuration values.

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇯🇴Jordan mohammad-fayoumi Amman

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

Comments & Activities

Production build 0.71.5 2024