Recently discovered an issue with layout builder IPE and specific entity embed use cases. If CMS user uses entity embed to embed a content block stemming from page B into the body of page A and then uses entity embed to embed a content block stemming from page A into the body of page B it will result in the error below when trying to visit either page. Note that I have content blocks set to not render the body field as it is disabled for content block display.
Fatal error: Nesting level too deep - recursive dependency? in /var/www/html/web/modules/contrib/layout_builder_ipe/layout_builder_ipe.module on line 53
Note: I replaced the layout_builder_ipe_entity_view_alter function in layout_builder_ipe.module with the below which resolved the issue for me.
/**
* Implements hook_entity_view_alter().
*
* This attaches the IPE frontend to entity displays.
*/
function layout_builder_ipe_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
$current_route_name = \Drupal::routeMatch()->getRouteName();
if (!$entity->id() || !$entity->hasLinkTemplate('canonical') || !$entity->toUrl()->isRouted() || $current_route_name != $entity->toUrl()->getRouteName()) {
// We can only act on full page views on the canonical url.
return;
}
$layout_builder_ipe = layout_builder_ipe_service();
$route_entity = $layout_builder_ipe->getContentEntityFromRoute();
if (!$route_entity || $entity->getEntityTypeId() != $route_entity->getEntityTypeId() || $entity->id() != $route_entity->id()) {
// This entity is not the routes main entity, so skip this.
return;
}
$section_storage = $layout_builder_ipe->getSectionStorage($display->getMode());
if (!$section_storage) {
return;
}
$can_override = $section_storage->getPluginId() == 'defaults' && $section_storage->isOverridable();
$is_overridden = $section_storage->getPluginId() == 'overrides';
if (!$can_override && !$is_overridden) {
return;
}
if (!$display->getThirdPartySetting('layout_builder_ipe', 'enabled', FALSE)) {
// Disabled in the display settings.
return;
}
$layout_builder_ipe->attachIpe($build, $section_storage, $entity);
}| Comment | File | Size | Author |
|---|
Issue fork layout_builder_ipe-3551518
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3551518-fatal-error-nesting
changes, plain diff MR !7
- 3551518-test-only
changes, plain diff MR !6
Comments
Comment #2
cybercoda commentedComment #3
berliner commentedOh, I missed this issue for some reason. Thanks for reporting!
Ideally this needs tests to move on.
Based on your changes I have created a preliminary patch for others to use in the meantime and for testing.
Comment #8
berliner commentedComment #10
berliner commentedComment #11
berliner commentedMerged. Thanks again for reporting @cybercoda!