WSOD when menu parent no longer exists
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3110502. -->
Reported by: [alison](https://www.drupal.org/user/453248)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>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.</p>
<ol>
<li>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.)</li>
<li>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).</li>
</ol>
<p>dblog:<br>
<code>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).</code></p>
<p>Menu position rule config for scenario #1:</p>
<pre>langcode: en<br>status: true<br>dependencies:<br> module:<br> - node<br>id: service_nodes<br>label: 'Service nodes'<br>menu_name: main<br>parent: 'views_view:views.services.brc_services_page'<br>menu_link: 'menu_position_link:service_nodes'<br>enabled: true<br>weight: 0<br>conditions:<br> node_type:<br> id: node_type<br> bundles:<br> service: service<br> negate: false<br> context_mapping:<br> node: '@node.node_route_context:node'</pre><p>
Scenario #2 config: The "parent" was <code>parent: 'menu_link_content:796c66fc-1f7d-462f-aa46-bdf69bc40155'</code>), and the condition was a <code>request_path</code> value instead of node_type.</p>
<p>.........<br>
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.<br>
(The menu_position_rule config entities' parent values were changed, of course -- for example, scenario #1: <code>parent: 'views_view:views.services.brc_tab_page'</code>.)</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>I'm not sure :)</p>
<p>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.</p>
<p>Besides that, just throwing stuff out there:</p>
<ul>
<li>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?</li>
<li>(Other ideas?)</li>
</ul>
<hr>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>(reviews needed, tests to be written or run, documentation to be written, etc.)</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>(New or changed features/functionality in the user interface, modules added or removed, changes to URL paths, changes to user interface text.)</p>
<h3 id="summary-api-changes">API changes</h3>
<p>(API changes/additions that would affect module, install profile, and theme developers, including examples of before/after code if appropriate.)</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>(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.)</p>
<h3 id="summary-release-notes">Release notes snippet</h3>
<p>(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)</p>
<h3 id="summary-original-report">Original report by [username]</h3>
<p>(Text of the original report, for legacy issues whose initial post was not the issue summary. Use rarely.)</p>
> Related issue: [Issue #3277980](https://www.drupal.org/node/3277980)
issue