Problem/Motivation

When placing/rendering an ogmenu_block on a Layout Builder page (e.g. /admin/structure/types/manage/{bundle}/display/full/layout), OG context may resolve without a persisted group entity ID. OgMenuBlock::build() still tries to generate entity.ogmenu_instance.create with og_group => '', which triggers:

Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "og_group" for route "entity.ogmenu_instance.create" must match "[^/]++" ("" given)

This causes a 500 AJAX error and can break rendering of the layout page.

Expected behaviour:

  • Block should not attempt to build the “Add menu” create link when OG context is missing/unsaved.
  • Page should render without fatal errors.

Proposed resolution

In OgMenuBlock::build(), guard create-link route generation behind a check that context is an entity with a non-empty ID.

Issue fork og_menu-3575559

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

joelpittet created an issue. See original summary.

joelpittet’s picture

Issue summary: View changes

joelpittet’s picture

Status: Active » Needs review
joelpittet’s picture

Issue summary: View changes
joelpittet’s picture

Status: Needs review » Fixed

Fixed (tests are red/green)

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.

  • joelpittet committed aad7af7d on 2.x
    fix: #3575559 OG Menu block crashes on Layout Builder defaults when OG...