Errors and warnings in Display Suite when managing taxonomy display with empty config

Created on 8 September 2024, 2 months ago
Updated 18 September 2024, 2 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

  • Issue created by @mohammad-fayoumi
  • Status changed to Needs review 2 months ago
  • 🇧🇪Belgium swentel

    Patch makes sense I guess. To be sure: which Drupal core version is this on, D11 of D10?

  • 🇵🇭Philippines paraderojether

    Hi mohammad-fayoumi,

    I was not able to reproduce the issue, my Drupal version is 10.3.2 with PHP version 8.3.6, can you please specify in what Drupal core version the issue occurred?

    Thank you.

  • 🇯🇴Jordan mohammad-fayoumi Amman

    I've encountered this issue with:

    • Drupal Version 10.3.2
    • PHP Version 8.2.23
  • Status changed to Postponed: needs info 2 months ago
  • 🇧🇪Belgium swentel

    Hmm, this would mean that this line would return nothing.

    $row = \Drupal::config($name)->get();
    

    Can you tell me the machine name of the vocabulary? Or maybe additional view modes that you have created?

  • 🇯🇴Jordan mohammad-fayoumi Amman

    I have a taxonomy with machine name and once I visit it's the manage display I got the reported 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).

    After some debugging I found this line return empty array.
    $row = \Drupal::config($name)->get();

    The issue appeared on visiting the default view mode.

  • Status changed to Active 2 months ago
  • 🇧🇪Belgium swentel

    Ok, thanks for the information! There might be a bug in core that fails to create the actual entity display maybe, however, we shouldn't fail on that of course. I have a different approach in my mind which I'll fix tomorrow.

Production build 0.71.5 2024