EntityReference sample value generation can break lazy builder in LayoutBuilder

Created on 10 December 2024, 4 months ago

Problem/Motivation

So this is a windy road of problems but main problem up front, when placing a lazy block on LB it can break the admin interface completely with a WSOD triggered by an invalid type.

The invalid type is the display id passed into the lazyBuilder method. But why?

Well the problem is that LB relies on the entity system to build a "sample" value for the LB preview. Because this module is built on top of core's EntityReference functionality that is handled by EntityReferenceItem::generateSampleValue. This is done very naively by selecting 50 entities of the type and picking a random one.

It seems this can lead to a view without a "valid" display getting chosen or the display being empty? I kinda lost the bug at this point but regardless the view is not likely to be useful.

Steps to reproduce

This seems to rely on some randomness but with some luck placing a lazy viewsreference field block on a LB page should recreate it.

Proposed resolution

There are some optimizations and checks that can be done in the ViewsReferenceLazyFieldFormatter::viewElements to workaround this. Probably core needs to do this better or this modules needs to override the sample generation to make more sense but that's not strictly necessary to fix this but and would be an additional enhancement.

Remaining tasks

User interface changes

n/a

API changes

n/a

Data model changes

n/a

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States neclimdul Houston, TX

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024