Gin Toolbar incompatible with 10.2.0-beta1 - MenuActiveTrail ($menu_link_manager) must be of type Menu\MenuLinkManagerInterface, DependencyInjection\Container given

Created on 26 November 2023, 7 months ago
Updated 19 January 2024, 5 months ago

(Opening the issue here, as this only effects the toolbar, not the wider Gin theme)

Problem/Motivation

After upgrading to 10.2.0-beta1 from the latest 10.1.6, we're encountering the following error on any page load:

Uncaught PHP Exception TypeError: "Drupal\\Core\\Menu\\MenuActiveTrail::__construct(): Argument #1 ($menu_link_manager) must be of type Drupal\\Core\\Menu\\MenuLinkManagerInterface, Drupal\\Core\\DependencyInjection\\Container given, called in /core/lib/Drupal/Component/DependencyInjection/Container.php on line 259" at /core/lib/Drupal/Core/Menu/MenuActiveTrail.php line 44

Disabling the Gin Toolbar resolves this issue site-wide,.

Steps to reproduce

Upgrade to 10.2.0-beta1, attempt to access any page with Gin Toolbar enabled.

Proposed resolution

The change made in 📌 Convert both BookNavigationCacheContext and MenuActiveTrailsCacheContext to use lazy services RTBC appears to have caused this, removing lazy: true from menu.active_trail resolves the issue, but defeats the purpose of the change.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom Hephaestus

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

Merge Requests

Comments & Activities

  • Issue created by @Hephaestus
  • First commit to issue fork.
  • First commit to issue fork.
  • Merge request !37First stab. → (Merged) created by Spokje
  • Status changed to Needs review 7 months ago
  • 🇳🇱Netherlands Spokje

    Looks like the GitLab CI pipeline was broken before I and my changes entered the stage, so going to put this on Needs Review despite the red flags there.

  • Assigned to Spokje
  • Status changed to Needs work 7 months ago
  • 🇫🇮Finland back-2-95 Helsinki

    This worked nicely with Drupal 10.2 RC1 and solved my issue.

  • 🇮🇳India mahtab_alam

    #4 MR fixed the issue for gin toolbar module on drupal 10.2.x

  • First commit to issue fork.
  • 🇨🇭Switzerland saschaeggi Zurich

    The MR just removes our modified menu trail service gin_toolbar.active_trail and swaps it for the core one which defeats the purpose of it. So this needs work to instead fix our service than removing it.

  • First commit to issue fork.
  • 🇪🇸Spain nireneko

    Updated the branch with another solution.

    The problem could be that Drupal tries to inject container and the proxy ID of the parent service because now is lazy.

  • Status changed to Needs review 7 months ago
  • 🇮🇳India mahtab_alam

    Yes it seems now we are not getting the issue with the latest solution.

  • 🇮🇳India mahtab_alam

    We can also add
    lazy: true to gin_toolbar.services.yml

  • 🇨🇭Switzerland saschaeggi Zurich

    Can somebody test the new solution from the MR so we can move ahead with a solution here?

    @mahtab_alam

    lazy: true to gin_toolbar.services.yml

    We might want to add it.

    Thank y'all in advance

  • Status changed to Needs work 7 months ago
  • 🇺🇸United States kevinfunk

    I've tested with Drupal 10.2.0-rc1 and it does fix the issue. However, on 10.1.7 I'm getting the error

    TypeError: Drupal\gin_toolbar\Menu\GinToolbarActiveTrail::__construct(): Argument #1 ($container) must be of type Drupal\Component\DependencyInjection\ContainerInterface, Drupal\Core\Menu\MenuLinkManager given, called in /home/ide/project/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 in Drupal\gin_toolbar\Menu\GinToolbarActiveTrail->__construct() (line 33 of /home/ide/project/docroot/modules/contrib/gin_toolbar/src/Menu/GinToolbarActiveTrail.php).

  • 🇺🇸United States mglaman WI, USA

    I think the fix to support 10.1 and 10.2 is to add lazy: true and generate a proxy service as well.

  • 🇺🇸United States mglaman WI, USA

    This worked for me:

    +     arguments: ['@plugin.manager.menu.link', '@current_route_match', '@cache.menu', '@lock']
    -      parent: menu.active_trail
    

    Remove the parent declaration. No need to modify constructor.

  • 🇪🇸Spain nireneko

    It works, thanks @mglaman.

  • Status changed to Needs review 7 months ago
  • Status changed to Needs work 7 months ago
  • 🇺🇸United States kevinfunk

    Thanks @mglaman.

    @nireneko can you update the MR to remove parent: menu.active_trail? I've manually made the change and it worked so once the MR has been updated, I should be able to set it to RTBC.

  • 🇺🇸United States jcontreras

    #22 - I can confirm that removing parent: menu.active_trail in the gin_toolbar.services.yml manially, and clearing the cache fixes the issue for me.

  • 🇨🇦Canada floydm

    Can confirm the same as #23 on the actual release of 10.2: the patch from MR !37 + removing that the parent: menu.active_trail line clears the error.

  • 🇪🇸Spain nireneko

    @kevinfunk, done!

  • Status changed to Needs review 6 months ago
  • Status changed to RTBC 6 months ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    This broke our sites tonight with the 10.2 release of Drupal core. The latest version of the MR as of #25 fixes the issue for us.

  • 🇺🇸United States DamienMcKenna NH, USA

    +1 for the patch, it resolves the 10.2 compatibility bug.

  • 🇨🇭Switzerland saschaeggi Zurich

    Tested on Drupal 9.2, 9.5, 10.0, 10.1 & 10.2

    Let's get this merged!

  • Issue was unassigned.
  • Status changed to Fixed 6 months ago
  • 🇨🇭Switzerland saschaeggi Zurich

    Released: https://www.drupal.org/project/gin_toolbar/releases/8.x-1.0-rc5

    Thanks y'all for participating in fixing this 👏

  • 🇺🇸United States mglaman WI, USA

    Cool :) I wonder if this could be "fixed" later using service decoration and checking the active theme (if Gin, do logic, otherwise delegate to inner) to avoid any further breaking changes.

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

  • Status changed to Fixed 5 months ago
  • 🇺🇸United States attheshow

    I'm repeatedly getting this error on one of my sites after updating to Drupal 10.2.2 and Gin Toolbar 8.x-1.0-rc5. Even after clearing the cache and running all database updates. Not sure what the problem is since it seems like everything is up-to-date.

Production build 0.69.0 2024