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);
}
CommentFileSizeAuthor
#3 3551518-3.patch675 bytesberliner
Command icon 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:

Comments

cybercoda created an issue. See original summary.

cybercoda’s picture

Issue summary: View changes
berliner’s picture

StatusFileSize
new675 bytes

Oh, 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.

  • berliner committed b4f99af9 on 1.0.x
    fix: #3551518 Fatal error: Nesting level too deep - recursive dependency...
berliner’s picture

Version: 1.0.0-beta10 » 1.0.x-dev
Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

berliner’s picture

berliner’s picture

Merged. Thanks again for reporting @cybercoda!