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
Comment | File | Size | Author |
---|---|---|---|
#15 | increase_recursive_render_limit-2828364-15.patch | 655 bytes | dabbor |
#4 | 2828364-4.patch | 3.31 KB | dawehner |
#4 | 2828364-4-fail.patch | 2.34 KB | dawehner |
#2 | 2828364-2.patch | 1.53 KB | dawehner |
Comments
Comment #2
dawehnerI'm writing tests for it still.
Comment #3
dawehnerComment #4
dawehnerHere is a test.
Comment #5
dawehnerA similar bug existed in entity_reference_override: #2828366: Mirror: ER formatter bug 2828364
Comment #7
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThis makes a lot of sense, thanks! :)
Comment #8
benjy CreditAttribution: benjy at PreviousNext commented+1, just ran into this in a similar scenario.
Comment #11
catchCommitted/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!
Comment #13
stevieb CreditAttribution: stevieb commentedI'm still seeing this error in 8.3.7
Comment #14
TrevorBradley CreditAttribution: TrevorBradley commentedI'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.
Comment #15
dabbor CreditAttribution: dabbor commentedWe encountered a problem with the
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
Comment #16
dabbor CreditAttribution: dabbor commentedBetter approach may be found in the issue https://www.drupal.org/project/drupal/issues/2940605, but there's no patch yet.
Comment #17
johnnydarkko CreditAttribution: johnnydarkko at Sage Tree Solutions commented#15 worked for me! Thanks @dabbor!
Comment #18
jonnyeom CreditAttribution: jonnyeom as a volunteer commented#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.
Comment #19
gngn CreditAttribution: gngn at Computer Manufaktur GmbH commented#15 works for me too.
Comment #20
jibran