Hi,
I've discovered a scenario that seems to create infinite recursion in the module. I have two nodes with an entity reference field, and each one references the other. Attempting to view the node page (even though that entity reference field was not being rendered in that view mode) led to a PHP fatal error, "Maximum function nesting level of '256' reached, aborting!".
This part of the backtrace is where it started (reading from bottom up):
Drupal\value\Normalizer\EntityReferenceFieldItemNormalizer->normalize(Object, 'value', Array) (Line: 143)
Symfony\Component\Serializer\Serializer->normalize(Object, 'value', Array) (Line: 21)
Drupal\value\Normalizer\FieldItemListNormalizer->normalize(Object, 'value', Array) (Line: 143)
Symfony\Component\Serializer\Serializer->normalize(Object, 'value', Array) (Line: 41)
Drupal\serialization\Normalizer\ComplexDataNormalizer->normalize(Object, 'value', Array) (Line: 20)
Drupal\value\Normalizer\ContentEntityNormalizer->normalize(Object, 'value', Array) (Line: 143)
Symfony\Component\Serializer\Serializer->normalize(Object, 'value') (Line: 38)
Drupal\value\ThemeManager->buildValues('node', Array) (Line: 22)
Drupal\value\ThemeManager->render('node', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
after which there is a repeating pattern of ->normalize() calls.
Checking out EntityReferenceFieldItemNormalizer, I think I understand what's going on - normalizing the entity reference field value steps into the referenced entity to normalize that, and when that points back at the first entity, the repeating pattern of calls occurs.
Probably the solution here will involve a check/limit on depth of normalizing referenced entities. What that depth limit should be, I'm not sure. :)
Comments
Comment #2
shadcn commentedI actually came across this bug too. I've been working on it. But got busy with other projects. I'll take a look at it again this week :)
Comment #4
shadcn commentedThis is now fixed. Feel free to reopen if you see any issues. Thank you.