Fatal Error When Referenced Item Deleted

Created on 19 February 2016, almost 9 years ago
Updated 23 October 2024, about 2 months ago

Problem/Motivation

When using Reference Table Formatter with a multivalue Entity Reference field (and potentially other types, though that is not tested) and one of the referenced entities is deleted without resaving the referencing entity you get the following error:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7880 of /home/public_html/includes/common.inc).

I traced this back to reference_table_formatter_base_type.inc line 247, where a call to field_get_items is made without verifying the $loaded_item is actually loaded.

Proposed Resolution

Wrap the remainder of the conditional in a check to see if this $loaded_item is empty:

if (!empty($loaded_item)) { ... }

This seems to solve the issue and just skips trying to render the broken relation.

I can write a patch for this after business hours, but I wanted to check if the empty() call seemed appropriate or if there was a better way to go about it.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dhansen

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

Merge Requests

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