Problem/Motivation
When saving a menu link, users on our site receive the following error: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "entity:menu_link_content:main" plugin does not exist.
Full stack trace:
#0 /opt/bitnami/drupal/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php(25): Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition()
#1 /opt/bitnami/drupal/web/core/lib/Drupal/Core/TypedData/TypedDataManager.php(303): Drupal\Core\Plugin\DefaultPluginManager->getDefinition()
#2 /opt/bitnami/drupal/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(145): Drupal\Core\TypedData\TypedDataManager->getCanonicalRepresentation()
#3 /opt/bitnami/drupal/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php(106): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode()
#4 /opt/bitnami/drupal/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php(93): Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate()
#5 /opt/bitnami/drupal/web/core/lib/Drupal/Core/TypedData/TypedData.php(132): Drupal\Core\TypedData\Validation\RecursiveValidator->validate()
#6 /opt/bitnami/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(518): Drupal\Core\TypedData\TypedData->validate()
#7 /opt/bitnami/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(188): Drupal\Core\Entity\ContentEntityBase->validate()
#8 [internal function]: Drupal\Core\Entity\ContentEntityForm->validateForm()
#9 /opt/bitnami/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array()
#10 /opt/bitnami/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(274): Drupal\Core\Form\FormValidator->executeValidateHandlers()
#11 /opt/bitnami/drupal/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm()
#12 /opt/bitnami/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(593): Drupal\Core\Form\FormValidator->validateForm()
#13 /opt/bitnami/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
#14 /opt/bitnami/drupal/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#15 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#16 /opt/bitnami/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#17 /opt/bitnami/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /opt/bitnami/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#19 /opt/bitnami/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#20 /opt/bitnami/drupal/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#21 /opt/bitnami/drupal/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#22 /opt/bitnami/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#23 /opt/bitnami/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#24 /opt/bitnami/drupal/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#25 /opt/bitnami/drupal/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#26 /opt/bitnami/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#27 /opt/bitnami/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#28 /opt/bitnami/drupal/vendor/asm89/stack-cors/src/Cors.php(53): Drupal\page_cache\StackMiddleware\PageCache->handle()
#29 /opt/bitnami/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Asm89\Stack\Cors->handle()
#30 /opt/bitnami/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#31 /opt/bitnami/drupal/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#32 /opt/bitnami/drupal/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#33 /opt/bitnami/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#34 /opt/bitnami/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#35 {main}
We have translation enabled on our site, and I noticed that new menu links have a Language field, while existing fields don't have a Language field. After noticing this I checked the database and found that new menu links are saved with a menu_link_content
bundle while the rest were saved with a bundle matching the machine name of their menu (in this case, almost all use main
for the Main navigation menu).
Steps to reproduce
- Install Drupal 10.5.1.
- Enable the taxonomy_menu_ui and the content_translation modules.
- Go to /admin/config/regional/content-language. Under Custom language settings, enable Custom menu link. Then, in the Custom menu link section, make Menu link title and Description translatable. Save the configuration.
- Go to /admin/structure/menu/manage/main. Edit an existing link to see if it has the Language field. If not, try saving the menu link. You should get the WSOD described above.
- Add a new menu link and save it. It should save without crashing.
Proposed resolution
I found
Changing menu bundle to current menu name is breaking menu structure (3501383)
π
Changing menu bundle to current menu name is breaking menu structure
Active
, which added an update hook to change the bundle for menu_link_content entities to menu_link_content. After attempting to install the patch from the fork associated with the issue, I found this todo item in the module's .install file:
/**
* TODO: Don't create hooks with names: taxonomy_menu_ui_update_9001 and taxonomy_menu_ui_update_9002.
*
* These hooks were created previously and deleted because of issues reports.
*/
That started me looking back at previous tags of the module starting with 3.0.4 (which is what we have installed) and moving up to 3.0.6. I found that taxonomy_menu_ui_update_9001
in version 3.0.4 is the culprit, and that taxonomy_menu_ui_update_9002
in 3501383's fork (see diffs) fixes it.
In my case, because the taxonomy_menu_ui_update_9002
hook has been removed from the module's latest release, I manually created a patch to re-add taxonomy_menu_ui_update_9002
to resolve the issue.
Remaining tasks
If this issue is affecting other sites besides mine, I'd suggest writing an update hook to undo the changes introduced in both taxonomy_menu_ui_update_9001
and taxonomy_menu_ui_update_9002
since both hooks have been removed from the module as of version 3.0.6. This would restore the menu_link_content
entities to their state from before the 3.0.4 release, which should resolve the issue without any additional changes.