PluginNotFoundException: "The "views_view:view.comment.page_published" plugin does not exist. Valid plugin IDs for Drupal\Core\Menu\LocalTaskManager are...

Created on 13 April 2023, over 1 year ago
Updated 19 April 2024, 8 months ago

Problem/Motivation

Receiving an intermittent error on a site:
Uncaught PHP Exception Drupal\Component\Plugin\Exception\PluginNotFoundException: "The "views_view:view.comment.page_published" plugin does not exist. Valid plugin IDs for Drupal\Core\Menu\LocalTaskManager are ...

The error can be fixed with a cache rebuild but it will eventually come back. The view it is looking for is a view with a page display which overrides the existing route for 'comment.admin'. This route is a local task on the 'content.admin' route and the error is thrown intermittently when we navigate to any local task on 'content.admin'.

Based on the code in Drupal\views\EventSubscriber\RouteSubscriber::alterRoutes, and Drupal\views\Plugin\views\display\PathPluginBase::alterRoutes, I don't believe the view should be an existing local task. It should only be looking for 'comment.admin'.

In PathPluginBase::collectRoutes the view display is added with route name 'view.comment.page_published' Later at RouteSubscriber::alterRoutes when views alters to override existing routes, it removes it as 'views.comment.page_published' but this does not exist. I think they should have the same name. If I change them to match then Drupal stops looking for the view route which is what I would expect.

Then, we have webform modules installed on our site and the local tasks get loaded up on webform's implementation of `hook_menu_links_discovered_alter` if you also have `admin_toolbar_tools` installed. This happens before views has set the altered list of routes in state variable 'views.view_route_names' and so views that are supposed to be overriding an existing route, get put into the local tasks using the view route instead of the overridden route. Views sets this data on event 'routing.route_finished'. If you don't load the local tasks before views sets it then everything seems to work fine, even though the route old view route isn't properly removed.

This is similar to https://www.drupal.org/project/drupal/issues/3164711 πŸ› Plugin doesn't exists error Closed: cannot reproduce and https://www.drupal.org/project/brightcove/issues/3270406 β†’ .

Steps to reproduce

- Add a page view that overrides an existing route which is a local task on another route (e.g. comment.admin is local task of content.admin).
- Load up local tasks during `hook_menu_links_discovered_alter`:
\Drupal::service('plugin.manager.menu.local_task')->getDefinitions();
which will put the views routes into the local task list instead of the route they are overriding.
- An intermittent issue usually happens at some point after cim/updb and cache clear when loading up the route.
- No other clear steps to reproduce at this point.

Short term resolution

- Cache clear: drush cr seems to resolve the issue until it surfaces again.

Long term resolution

- Fix name of route removed from the collection, run views subscriber to routing.route_finished before hook_menu_links_discovered_alter is run.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated 2 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States kleinmp

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024