Immediately after enabling menu_item_extras for the first time and then adding a menu link in Main navigation, when I hit the Save button I got "The website encountered an unexpected error. Please try again later."

Update: I think Layout Builder was enabled.

And this is the error I saw in the watchdog:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "entity:menu_link_content:main" plugin does not exist. Valid plugin IDs for Drupal\Core\TypedData\TypedDataManager are: (...long list of plugins...) in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /var/www/drupalvm/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

I cleared caches using Drush. Successfully went back to the home page. Then back to admin/structure/menu/manage/main where I saved without making any changes and, finally, I was able to add a menu link, no error this time, all seems normal as if now the system was aware of the plugin that it was initially complaining about.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bisonbleu created an issue. See original summary.

voleger’s picture

Priority: Normal » Critical
Status: Active » Needs work
StatusFileSize
new989 bytes

Thanks for STR. The error was reproduced.
I had attached the test coverage. So we need to fix the test.

bisonbleu’s picture

Issue summary: View changes

Note: I think Layout Builder was enabled when I added the link that caused this php error. Adding a note in the issue summary in case this is relevant.

jeffam’s picture

I ran into a similar error when I tried to add a link to a programmatically created menu.

The menus are created with code something like this:

$collection_machine_name = 'subsite-50';
$menu = $this->entityTypeManager->getStorage('menu')->create([
  'langcode' => 'en',
  'status' => TRUE,
  'id' => $collection_machine_name,
  'label' => $collection->label() . ' subsite main navigation',
  'description' => 'Auto-generated menu for ' . $collection->label() . ' subsite',
]);
$menu->save();

When I try to save a link to the menu, I get the following.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "entity:menu_link_content:subsite-50" plugin does not exist

Clearing caches allows me to save links to the menu without further errors.

jeffam’s picture

Since flushing all of the caches prevents the error, I looked through drupal_flush_all_caches() and, based on what happens in there, I found that the following can be run after a programmatically-created menu is saved:

\Drupal::service('cache.discovery')->deleteAll();
\Drupal::service('kernel')->rebuildContainer();

This prevents the PluginNotFoundException error from the TypedDataManager when I later try to add a menu link to the new menu.

daveferrara1’s picture

StatusFileSize
new759 bytes

We have a similar issue where we get this error if we create a new menu and then immediately use the the add link button. When we attempt to save the new link, we receive the Drupal\Component\Plugin\Exception\PluginNotFoundException. Likely similar to https://www.drupal.org/node/2773591 where we need cache emptied. Here is a small patch to do it if we have a menu insert.

daveferrara1’s picture

StatusFileSize
new759 bytes
sarathkm’s picture

Status: Needs work » Needs review
marcoka’s picture

I can confirm this happening here too. I also canconfirm flushing the caches fixes this.
To reproduce i created a new menu and directly tried to add a link.

david.chevillet’s picture

I confirm the bug. The patch seems to fix it too, even if when creating a menu slow down a little bit the first link added, but we don't creat a menu every day. Thanks !

marchudson’s picture

I had the same issue described above which the patch fixed. But unfortunately it's back elsewhere.

Steps:
I installed the patch, flushed cache, created menu items successfully, selected some view modes on the VM Settings tab, added an (existing) field and finally I got the error after selecting label: "Hidden" on the Manage Display page.

Error (white screen o' death):
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "hidden" plugin does not exist. Valid plugin IDs for Drupal\Core\Field\FormatterPluginManager are: .....

ivan ojiambo’s picture

I ran into this error, clearing the cache helped me get rid of the error

ozin made their first commit to this issue’s fork.

ozin’s picture

Assigned: Unassigned » ozin
StatusFileSize
new1.75 KB

Please check if the latest patch works for you.
Thanks!

tolu_’s picture

Status: Needs review » Reviewed & tested by the community

#15 works for me

ozin’s picture

@tolu_ thanks for the review!

  • ozin committed 0d1cc40 on 8.x-2.x
    Issue #3061342 by daveferrara1, voleger, ozin: The entity:...
ozin’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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