Fatal error after upgrading to Drupal 10.2

Created on 21 December 2023, 6 months ago
Updated 10 January 2024, 6 months ago

Problem/Motivation

Fatal error: Declaration of Drupal\menu_link_config\Plugin\Menu\MenuLinkConfig::getEntity() must be compatible with Drupal\menu_link_content\Plugin\Menu\MenuLinkContent::getEntity(): Drupal\menu_link_content\MenuLinkContentInterface in /Users/...../web/modules/contrib/menu_link_config/src/Plugin/Menu/MenuLinkConfig.php on line 87

Steps to reproduce

The site successfully upgraded but I get this error on some pages now

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇺🇸United States loze

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @loze
  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & sqlite-3.27
    last update 6 months ago
    Waiting for branch to pass
  • Status changed to Needs review 6 months ago
  • 🇺🇸United States loze

    This fixes the error for me and I am able to use the site now.

  • Status changed to Needs work 6 months ago
  • 🇺🇸United States loze

    Actually after further testing, this doesn't solve the issue.

  • Assigned to Anita verma
  • Issue was unassigned.
  • First commit to issue fork.
  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & sqlite-3.27
    last update 6 months ago
    Waiting for branch to pass
  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & sqlite-3.27
    last update 6 months ago
    Waiting for branch to pass
  • Status changed to Needs review 6 months ago
  • 🇧🇪Belgium daften

    I've updated the MR with a patch that works for me. I made the MenuLinkConfig plugin independent from menu_link_content, which should also fix the todo that was still there.

    It's only tested briefly, so please thoroughly. I see e.g. in the menu editing for menu link config items that the machine name is not populated, not sure if that was there before.

  • 🇧🇪Belgium daften

    Updating the title, this seems to be new since Drupal 10.2 specifically

  • 🇨🇦Canada joelpittet Vancouver

    @daften, The only change here is the interface change or did you both run into other changes needed?

    This seems like the only change needed to fix this problem:

    -  public function getEntity() {
    +  public function getEntity(): MenuLinkConfigInterface {
    

    Alternatively you could change to the decorator instead of extending and avoid these kind of bugs. Would that be an OK direction for this issue?

  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & sqlite-3.27
    last update 6 months ago
    Waiting for branch to pass
  • 🇦🇲Armenia armrus

    There is a patch for module update after upgrading.

Production build 0.69.0 2024