Problem/Motivation

Getting below error when adding/ editing menu link from group content menu after update from Drupal 10.1.7 to Drupal 10.2.0
Error: Call to a member function label() on null in Drupal\menu_link_content\Form\MenuLinkContentForm->form() (line 99 of /var/www/html/docroot/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php).

Steps to reproduce

1. Install group content menu.
2. Install group as well.
3. Then, Create menus type under the group content menu.
4. Now, Install the menu for the group type under the group content setting.
5. Try to add new link on group menu.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3411384

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

venkatadapa created an issue. See original summary.

venkatadapa’s picture

StatusFileSize
new748 bytes

Attached a patch

shashank5563’s picture

Status: Needs review » Reviewed & tested by the community

@venkatadapa, Thank you, I have tested this on my project and found it is working as expected.

I am moving it for RTBC.

shashank5563’s picture

Issue summary: View changes
cilefen’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Drupal 10.2 bug +Needs tests

This patch has not been tested.

Is this something that should be fixed in the contributed module?

There must be missing tests of this is a core bug, and a regression.

banoodle’s picture

I upgraded to Drupal 10.2.2 and I also can no longer add links to Group menus.

Patch #2 fixes the issue for me, but I have created this task in the Group Content Menu issue queue to get visibility with the maintainers of that module: https://www.drupal.org/project/group_content_menu/issues/3417879

In the meantime, I'm going to have to use the patch on this issue - so thanks!

damienmckenna’s picture

Assigned: venkatadapa » Unassigned
heddn’s picture

Traced this back to #3110371: When adding a new menu link, restrict the available parents to the current menu. It isn't in 10.1 but is in 10.2. GCM does not have a full config backed menu. It never will. Additionally, the menu parent logic is overwritten by that module after this here. The patch in #2 seems like a decent solution. An entity load can fail to load (that's what we see here). We should check and handle appropriately.

Still needs tests, but this can be easily reproduced. In a test controller add something like:

  public function addLink(GroupContentMenuInterface $group_content_menu) {
    $menu_name = 'non-existent';
    $menu_link = $this->entityTypeManager()->getStorage('menu_link_content')->create([
      'menu_name' => $menu_name,
      'bundle' => 'menu_link_content',
    ]);
    return $this->entityFormBuilder()->getForm($menu_link);
  }

Version: 10.2.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

karimb’s picture

Just to mention that I applied the patch #2 and it works for me! Thanks.

phthlaap made their first commit to this issue’s fork.

alecsmrekar made their first commit to this issue’s fork.

alecsmrekar’s picture

Status: Needs work » Needs review

plach made their first commit to this issue’s fork.

plach’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Looks good and works well here, I pushed a small commit to address @graber's review.

I only changed a word in a comment, so I think it's fine for me to RTBC this :)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Made some comments on the MR with a suggested change.

phthlaap’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Appears suggestions by @alexpott has been addressed.

alexpott credited Graber.

alexpott’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 84432de226 to 11.x and cf919c8960 to 10.3.x and 22add58ea6 to 10.2.x. Thanks!

  • alexpott committed 22add58e on 10.2.x
    Issue #3411384 by phthlaap, venkatadapa, alecsmrekar, plach, alexpott,...

  • alexpott committed cf919c89 on 10.3.x
    Issue #3411384 by phthlaap, venkatadapa, alecsmrekar, plach, alexpott,...

  • alexpott committed 84432de2 on 11.x
    Issue #3411384 by phthlaap, venkatadapa, alecsmrekar, plach, alexpott,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.