Exception if entity reference is not valid (got deleted)

Created on 11 October 2022, almost 2 years ago
Updated 10 July 2023, about 1 year ago

Problem/Motivation

If the entity reference used for the link for some reason (entity was deleted) does no longer exist, field group link creates an exception:

Call to a member function toUrl() on null in Drupal\field_group_link\Plugin\field_group\FieldGroupFormatter\Link->getUrlFromField()

While it is probably bad habit to delete entities that are referenced elsewhere, this is something that can (easily) happen and should not result in WSOD imho.

Steps to reproduce

  • Use a reference field for the link
  • delete the entity that is referenced in the field
  • visit the page where the link should be shown

Proposed resolution

Check if there is a valid entity reference (like there is already a check for a valid file entity if file is used) and skip the url generation if there is no valid entity reference

Remaining tasks

User interface changes

na

API changes

na

Data model changes

na

🐛 Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

🇩🇪Germany stefan.korn Jossgrund

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024