WSOD when menu parent no longer exists

Created on 31 January 2020, over 4 years ago
Updated 31 May 2023, over 1 year ago

Problem/Motivation

In both of the following scenarios, we got a WSOD on the menu position rules list page (admin/structure/menu-position), and we got a WSOD when we viewed any page targeted by the menu position rule.

  1. A menu position rule that's applied to node pages of a content type. The "parent menu item" in the rule is a menu link that comes from a view page display. The view page display machine name ended up being changed for template reasons, and then, the parent item "no longer existed," so to speak. (Then, WSOD -- see above.)
  2. A menu position rule that's applied to a page with a specific path. The "parent menu item" is a regular menu link to a basic page on the site. I deleted that menu link (the parent link) from the main menu, and then, the parent item no longer existed (and then, WSOD -- see above).

dblog:
Drupal\Component\Plugin\Exception\PluginNotFoundException: Plugin ID '' was not found. in Drupal\Core\Menu\MenuLinkManager->getDefinition() (line 206 of /path/to/core/lib/Drupal/Core/Menu/MenuLinkManager.php).

Menu position rule config for scenario #1:

langcode: en
status: true
dependencies:
  module:
    - node
id: service_nodes
label: 'Service nodes'
menu_name: main
parent: 'views_view:views.services.brc_services_page'
menu_link: 'menu_position_link:service_nodes'
enabled: true
weight: 0
conditions:
  node_type:
    id: node_type
    bundles:
      service: service
    negate: false
    context_mapping:
      node: '@node.node_route_context:node'

Scenario #2 config: The "parent" was parent: 'menu_link_content:796c66fc-1f7d-462f-aa46-bdf69bc40155'), and the condition was a request_path value instead of node_type.

.........
Fortunately, the rule editing pages worked, so I went directly to those URLs (admin/structure/menu-position/service_nodes), selected a "parent menu item", saved it, and everything was fine again.
(The menu_position_rule config entities' parent values were changed, of course -- for example, scenario #1: parent: 'views_view:views.services.brc_tab_page'.)

Proposed resolution

I'm not sure :)

For starters, just a less disruptive breakage would be great -- like, maybe the rule simply doesn't apply, but you don't get a WSOD.

Besides that, just throwing stuff out there:

  • In the Drupal core universe, if I have a view page that has a menu item configured with it, and the parent menu item of that view page menu item goes away, I think the menu item just gets bumped out to the "grandparent" menu item, right? So maybe the menu_position could behave like that?
  • (Other ideas?)

Remaining tasks

(reviews needed, tests to be written or run, documentation to be written, etc.)

User interface changes

(New or changed features/functionality in the user interface, modules added or removed, changes to URL paths, changes to user interface text.)

API changes

(API changes/additions that would affect module, install profile, and theme developers, including examples of before/after code if appropriate.)

Data model changes

(Database or configuration data changes that would make stored data on an existing site incompatible with the site's updated codebase, including changes to hook_schema(), configuration schema or keys, or the expected format of stored data, etc.)

Release notes snippet

(Major and critical issues should have a snippet that can be pulled into the release notes when a release is created that includes the fix)

Original report by [username]

(Text of the original report, for legacy issues whose initial post was not the issue summary. Use rarely.)

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States alison

Live updates comments and jobs are added and updated live.
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