After installing Menu Token 8.x-1.0-alpha3 via composer, enabling it in admin panel and subsequent uninstallation (without any changes in settings) site immediately crashes with "unexpected error - try again later".
This occurs under Drupal core 8.7.9.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

_kom__ created an issue. See original summary.

Jack2222’s picture

Yes, I just got the same issue. I tried on two sites and both crashed after uninstalled.

eahonet’s picture

I can see patch-5 in the code from https://www.drupal.org/project/menu_token/issues/3047794, I'm on the latest -dev of menu_token. But the site will no longer work if I try to uninstall the module.

  1. installed menu_token
  2. created a new menu item using it
  3. went a different path so deleted the menu item
  4. uninstalled menu_token
  5. the site won't load

Here's the error I get. Clear cache, uninstalling in /admin vs drush, updb, etc. Nothing seems to be working.

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Symfony\Component\Routing\Exception\RouteNotFoundException</em>: Route &quot;menu_token.available_entities_configuration_form&quot; does not exist. in <em class="placeholder">Drupal\Core\Routing\RouteProvider-&gt;getRouteByName()</em> (line <em class="placeholder">201</em> of <em class="placeholder">core/lib/Drupal/Core/Routing/RouteProvider.php</em>). <pre class="backtrace">Drupal\Core\Routing\UrlGenerator-&gt;getRoute(&#039;menu_token.available_entities_configuration_form&#039;) (Line: 130)
Drupal\Core\Routing\UrlGenerator-&gt;getPathFromRoute(&#039;menu_token.available_entities_configuration_form&#039;, Array) (Line: 68)
Drupal\Core\Render\MetadataBubblingUrlGenerator-&gt;getPathFromRoute(&#039;menu_token.available_entities_configuration_form&#039;, Array) (Line: 790)
Drupal\Core\Url-&gt;getInternalPath() (Line: 135)
Drupal\Core\Utility\LinkGenerator-&gt;generate(&#039;Menu token, used entities.&#039;, Object) (Line: 94)
Drupal\Core\Render\Element\Link::preRenderLink(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension-&gt;escapeFilter(Object, Array, &#039;html&#039;, NULL, 1) (Line: 117)
__TwigTemplate_dfd7eb4fd70ed2786525014e5ceac8f838aadfbd4f9a8be0255e23d358ba7efe-&gt;getmenu_links(Array, Object, 0) (Line: 60)
__TwigTemplate_dfd7eb4fd70ed2786525014e5ceac8f838aadfbd4f9a8be0255e23d358ba7efe-&gt;doDisplay(Array, Array) (Line: 455)
Twig\Template-&gt;displayWithErrorHandling(Array, Array) (Line: 422)
Twig\Template-&gt;display(Array) (Line: 434)
Twig\Template-&gt;render(Array) (Line: 64)
twig_render_template(&#039;core/themes/stable/templates/navigation/menu--toolbar.html.twig&#039;, Array) (Line: 384)
Drupal\Core\Theme\ThemeManager-&gt;render(&#039;menu__toolbar&#039;, Array) (Line: 437)
Drupal\Core\Render\Renderer-&gt;doRender(Array, 1) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array, 1) (Line: 151)
Drupal\Core\Render\Renderer-&gt;Drupal\Core\Render\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 152)
Drupal\Core\Render\Renderer-&gt;renderPlain(Array) (Line: 340)
_toolbar_do_get_rendered_subtrees(Array)
call_user_func(&#039;_toolbar_do_get_rendered_subtrees&#039;, Array) (Line: 378)
Drupal\Core\Render\Renderer-&gt;doRender(Array, 1) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array, 1) (Line: 151)
Drupal\Core\Render\Renderer-&gt;Drupal\Core\Render\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 152)
Drupal\Core\Render\Renderer-&gt;renderPlain(Array) (Line: 310)
toolbar_get_rendered_subtrees() (Line: 368)
_toolbar_get_subtrees_hash() (Line: 167)
toolbar_toolbar()
call_user_func_array(&#039;toolbar_toolbar&#039;, Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler-&gt;invokeAll(&#039;toolbar&#039;) (Line: 81)
Drupal\toolbar\Element\Toolbar::preRenderToolbar(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer-&gt;doRender(Array) (Line: 450)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension-&gt;escapeFilter(Object, Array, &#039;html&#039;, NULL, 1) (Line: 98)
__TwigTemplate_b0b65829004866aa7340bb0cba89c443ab3e94ec63f0ad0a399d014d36466428-&gt;doDisplay(Array, Array) (Line: 455)
Twig\Template-&gt;displayWithErrorHandling(Array, Array) (Line: 422)
Twig\Template-&gt;display(Array) (Line: 434)
Twig\Template-&gt;render(Array) (Line: 64)
twig_render_template(&#039;core/themes/classy/templates/layout/html.html.twig&#039;, Array) (Line: 384)
Drupal\Core\Theme\ThemeManager-&gt;render(&#039;html&#039;, Array) (Line: 437)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array) (Line: 147)
Drupal\Core\Render\MainContent\HtmlRenderer-&gt;Drupal\Core\Render\MainContent\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 148)
Drupal\Core\Render\MainContent\HtmlRenderer-&gt;renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber-&gt;onViewRenderArray(Object, &#039;kernel.view&#039;, Object)
call_user_func(Array, Object, &#039;kernel.view&#039;, Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher-&gt;dispatch(&#039;kernel.view&#039;, Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
</pre>
DevElCuy’s picture

New core, old bug. Drupal is not friendly when dealing with lost routes. Yet, we have a mixed situation here. Because, the menus are user data and they should never be deleted without user consent. Yet, we can't let all those route created by menu_token stay hidden and perhaps conflicting with other routes. Long history short, Menu Token module can't be uninstalled without cleaning up the route tree and perhaps we need new config form where the user can clear all menu token routes.

Jack2222’s picture

Anybody knows if this issue is resolved with the new Drupal core 8.8.0?

_kom__’s picture

It is not a core issue. Site crashes without any changes in configuration or menu items.

akshaynikte@gmail.com’s picture

I have installed this module on client site and now I am stuck.

I cannot uninstall this module, any tweak or manual way to uninstall the module will help me a lot.

Getting following error:

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Symfony\Component\Routing\Exception\RouteNotFoundException</em>: Route &quot;menu_token.available_entities_configuration_form&quot; does not exist. in <em class="placeholder">Drupal\Core\Routing\RouteProvider-&gt;getRouteByName()</em> (line <em class="placeholder">201</em> of <em class="placeholder">core\lib\Drupal\Core\Routing\RouteProvider.php</em>).

maria.dis’s picture

I have the site down because of that. Any solution?

ajaybhaskar’s picture

The website encountered an unexpected error. Please try again later.Symfony\Component\Routing\Exception\RouteNotFoundException: Route "menu_token.available_entities_configuration_form" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 201 of core/lib/Drupal/Core/Routing/RouteProvider.php).

Drupal\Core\Routing\UrlGenerator->getRoute('menu_token.available_entities_configuration_form') (Line: 130)

My site is not working and showing this error on every page after uninstall menu token module.
So any solutions?
bradallenfisher’s picture

if you simply want to uninstall the module just comment out line 31 in menu_token.install file

it looks like this
$query->condition('mr.menu_name', $menus, 'IN');

comment that line out then uninstall the module and remove it from your code base.

Sleeepy’s picture

I had the exact same issue. #10 did not do the trick for me, but it showed me the way.
I had to comment out line 29-33.

#$query = $connection->select('menu_tree', 'mr')
# ->fields('mr', ['mlid']);
#$query->condition('mr.menu_name', $menus, 'IN');
#$query->condition('mr.discovered', 1, '=');
#$results = $query->execute();

And then I was able to uninstall.

MiklosMatyas’s picture

Thanks Sleeepy,
#11 worked for me.

JasonLuttrell’s picture

When I uninstalled, I got a different error message:

[error] Error: __clone method called on non-object in Drupal\Core\Routing\UrlGenerator->getRoute() (line 426 of /PATH/TO/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php)

asilva3’s picture

confirming #11 did the trick for me

webengr’s picture

#10 almost worked, had to reinstall then do #11 and uninstall, weird.

I was using "upgrade_status" and removing modules not drupal 9 ready, and it was suggested to remove this module, but I got error, had to go to install file and comment out those lines.

Was getting
$ drush9 pm:uninstall menu_token

In Condition.php line 105:

Query condition 'mr.menu_name IN ()' cannot be empty.

DevElCuy’s picture

Version: 8.x-1.0-alpha3 » 9.1.x-dev
PrabuEla’s picture

I too faced same error

When I hide these below lines in menu_tocken.install it works for me.

// $query = $connection->select('menu_tree', 'mr')
// ->fields('mr', ['mlid']);
// $query->condition('mr.menu_name', $menus, 'IN');
// $query->condition('mr.discovered', 1, '=');
// $results = $query->execute();

bbu23’s picture

This is definitely a difficult bugfix, that's why I will provide a patch that might not work for everybody and I am not creating a MR. After checking a bit, there's the MenuTokenTreeStorage service that sets almost all menu items in menu_tree to discovered=1. But then when the uninstall happens, the queries performed there grab almost all menu items and sets the discoverability to 0. This can cause problems depending on the way the menu item is provided.

For now, I don't see a way to restore the original data from the menu_tree when we talk about the discovered flag, but what we can avoid (at least for people who installed the module and didn't do many changes or none) is to allow the the uninstall hook to set almost ALL menu items as not discovered, especially the ones that have special providers.

For example, the error in comment #3 is caused by setting the menu item provided by the module itself as discovered 0. Therefore, for my small investigation and my particular case, I added a condition to the last query to not affect the menu items that have a provider other than menu_link_content. Maybe we can start from here, would love to hear some feedback from people that had done more with this module before uninstalling.

Also, it's worth reading about the https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Menu%21me... hook that it's used by the menu_token module as well.

eswiderski’s picture

This module destroyed a bunch of my custom menus. STAY AWAY.

gshreeGS’s picture

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Symfony\Component\Routing\Exception\RouteNotFoundException</em>: Route &quot;menu_token.available_entities_configuration_form&quot; does not exist. in <em class="placeholder">Drupal\Core\Routing\RouteProvider-&gt;getRouteByName()</em> (line <em class="placeholder">201</em> of <em class="placeholder">core\lib\Drupal\Core\Routing\RouteProvider.php</em>).

To resolve this error, go to your database and run the SQL query:
SELECT * FROM menu_tree WHERE route_name="menu_token.available_entities_configuration_form";
And delete that entry.

Site should be working fine

rex.barkdoll’s picture

Hi, I'm prepping a site for D10 and ran into this issue trying to uninstall 9.1.0-alpha1 from the site.

Patch #5 from comment six on https://www.drupal.org/project/menu_token/issues/3047794#comment-13213420 did NOT work for me.

I do want to thank gshreeGS for their database modification suggestion in #20. I unchecked the entity types on the menu token page and then removed that single entry from the menu tree table and the uninstall went fine.

I'm not sure if there's anything the developers can do to clean up the install process, that would be massively helpful. I remember this module being a pain in the past.

edward.peters’s picture

Thank you gshreeGS and rex.barkdoll. This worked for me.

paper boy’s picture

The solution in #20 is working well for me on Drupal 9.5.11 when performing the following steps:

Uncheck all options from Menu Token config at /admin/config/menu_token

Disable the module:

drush -y pmu menu_token

Remove the dead route:

drush sql:query "DELETE from menu_tree WHERE route_name = 'menu_token.available_entities_configuration_form'"

Rebuild cache:

drush cr