Problem/Motivation

When a term level does not exist anymore but there is an old value in the database, then a PHP warning can occur:

Warning: Undefined array key 5 in Drupal\term_level\Plugin\Field\FieldFormatter\TermLevelFormatter->viewElements() (line 34

Steps to reproduce

Add field values with a certain term level, then remove that level. On display the warning will happen.

Proposed resolution

Do not show term level for invalid levels that don't exist anymore.

Remaining tasks

Merge request work.

User interface changes

Invalid term levels will be hidden.

API changes

none

Data model changes

none

Issue fork term_level-3550773

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

klausi created an issue. See original summary.

klausi’s picture

Status: Active » Needs review

merge request ready.

tibezh’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thank you @klausi!

  • klausi committed 45f0bed6 on 8.x-1.x
    fix(formatter): Fix PHP warning on invalid level values (#3550773)
    
klausi’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.