Problem/Motivation

We use a media entity based approach on this website. In there the image field, has a fallback default media, to ensure, we always render at least something,
so that for example the layout isn't destroyed. This is implemented by having a default value on the field_image entity reference field, pointing to a specific media instance.

Problem

We saw images not being rendered on the bottom of the image. Further up, things were totally fine. Thanks to Drupal though, we seem to have some helpful error messages:

Recursive rendering detected when rendering entity media: 11, using the field_image field on the article bundle. Aborting rendering.

We checked the various media configurations, and there was no recursive rendering going on.
Instead all what happened was that the default image was rendered more than 20 times in total on the frontpage, so images further below, simply stopped doing anything.

Proposed resolution

Enhance the recursion protection to include not only the referenced but also the referencing entity.

Remaining tasks

  • Confirm that this is in general the right way to fix it
  • Reviews
  • Take feedback into account
  • Commit

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner created an issue. See original summary.

dawehner’s picture

Issue tags: +Needs tests
FileSize
1.53 KB

I'm writing tests for it still.

dawehner’s picture

Status: Active » Needs review
dawehner’s picture

dawehner’s picture

A similar bug existed in entity_reference_override: #2828366: Mirror: ER formatter bug 2828364

The last submitted patch, 4: 2828364-4-fail.patch, failed testing.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

This makes a lot of sense, thanks! :)

benjy’s picture

+1, just ran into this in a similar scenario.

  • catch committed 65a01a7 on 8.3.x
    Issue #2828364 by dawehner: Default media stopped to render due to...

  • catch committed a24ad5f on 8.2.x
    Issue #2828364 by dawehner: Default media stopped to render due to...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!

Status: Fixed » Closed (fixed)

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

stevieb’s picture

I'm still seeing this error in 8.3.7

TrevorBradley’s picture

I'm also seeing this in 8.3.7. I'm building a large Search API Index with lots of nested content types as entity references. It's possible I might be rendering the same node 50 times in a given Search API Indexing.

I'm going to try reducing my Search API indexing to 20 at a time to match up with RECURSIVE_RENDER_LIMIT.

dabbor’s picture

We encountered a problem with the

Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceEntityFormatter::RECURSIVE_RENDER_LIMIT

while running Acquia Lightning update command drupal update:lightning 2.2.0 --no-interaction

As a workaround we want to use a patch to increase the RECURSIVE_RENDER_LIMIT from 20 to 60 (this number work for us) and use the patch for a short while when updating our projects.

Here is the patch changing the RECURSIVE_RENDER_LIMIT in the file: docroot/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php

dabbor’s picture

Better approach may be found in the issue https://www.drupal.org/project/drupal/issues/2940605, but there's no patch yet.

johnnydarkko’s picture

#15 worked for me! Thanks @dabbor!

jonnyeom’s picture

#15 worked for me as well.

I am not sure how to handle the situation here.
Should we open a new issue? or attach this patch to https://www.drupal.org/project/drupal/issues/2940605 as temporary workaround?

I don't think this patch should live under a closed issue.

gngn’s picture

#15 works for me too.

jibran’s picture

Issue tags: +DER issue