Comment bulk delete triggers PluginNotFoundException

Created on 12 February 2025, about 2 months ago

Problem/Motivation

When using the bulk delete for comments, we get a PluginNotFoundException: 'The "entity:delete_action:comment" plugin does not exist.' The error doesn't happen when we delete a single comment by going to the comment page, clicking the Delete tab and confirming the delete.

Full error:

he website encountered an unexpected error. Try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "entity:delete_action:comment" plugin does not exist. Valid plugin IDs for Drupal\Core\Action\ActionManager are: node_assign_owner_action, node_unpublish_by_keyword_action, comment_unpublish_by_keyword_action, convert_bundles_action_base, node_make_sticky_action, node_promote_action, node_unpromote_action, node_make_unsticky_action, user_block_user_action, user_remove_role_action, user_add_role_action, user_unblock_user_action, user_cancel_user_action, entity:delete_action:media, entity:delete_action:node, action_message_action, entity:publish_action:block_content, entity:publish_action:comment, entity:publish_action:media, entity:publish_action:node, entity:publish_action:path_alias, entity:publish_action:taxonomy_term, entity:publish_action:menu_link_content, action_goto_action, action_send_email_action, entity:save_action:block_content, entity:save_action:comment, entity:save_action:file, entity:save_action:media, entity:save_action:node, entity:save_action:taxonomy_term, entity:save_action:user, entity:save_action:menu_link_content, entity:unpublish_action:block_content, entity:unpublish_action:comment, entity:unpublish_action:media, entity:unpublish_action:node, entity:unpublish_action:path_alias, entity:unpublish_action:taxonomy_term, entity:unpublish_action:menu_link_content in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Drupal\Core\Plugin\DefaultPluginManager->getDefinition() (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance() (Line: 62)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->initializePlugin() (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get() (Line: 18)
Drupal\Core\Action\ActionPluginCollection->get() (Line: 88)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->setConfiguration() (Line: 104)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->addInstanceId() (Line: 55)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->__construct() (Line: 114)
Drupal\system\Entity\Action->getPluginCollection() (Line: 130)
Drupal\system\Entity\Action->getPlugin() (Line: 424)
Drupal\views\Plugin\views\field\BulkForm->viewsFormSubmit() (Line: 192)
Drupal\views\Form\ViewsFormMainForm->submitForm() (Line: 190)
Drupal\views\Form\ViewsForm->submitForm()
call_user_func_array() (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)
Drupal\Core\Form\FormBuilder->processForm() (Line: 326)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 224)
Drupal\Core\Form\FormBuilder->getForm() (Line: 2265)
Drupal\views\Plugin\views\display\DisplayPluginBase->elementPreRender()
call_user_func_array() (Line: 113)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 870)
Drupal\Core\Render\Renderer->doCallback() (Line: 432)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

We first thought it was related to https://www.drupal.org/project/drupal/issues/3045570 , implemented the custom module described in #21, but doing a drush updatedb triggers the same exception:

>  [notice] Update started: fix_comment_delete_error_update_910002
>  [error]  The "entity:delete_action:comment" plugin does not exist. Valid plugin IDs for Drupal\Core\Action\ActionManager are: node_assign_owner_action, node_unpublish_by_keyword_action, comment_unpublish_by_keyword_action, convert_bundles_action_base, node_make_sticky_action, node_promote_action, node_unpromote_action, node_make_unsticky_action, user_block_user_action, user_remove_role_action, user_add_role_action, user_unblock_user_action, user_cancel_user_action, entity:delete_action:media, entity:delete_action:node, action_message_action, entity:publish_action:block_content, entity:publish_action:comment, entity:publish_action:media, entity:publish_action:node, entity:publish_action:path_alias, entity:publish_action:taxonomy_term, entity:publish_action:menu_link_content, action_goto_action, action_send_email_action, entity:save_action:block_content, entity:save_action:comment, entity:save_action:file, entity:save_action:media, entity:save_action:node, entity:save_action:taxonomy_term, entity:save_action:user, entity:save_action:menu_link_content, entity:unpublish_action:block_content, entity:unpublish_action:comment, entity:unpublish_action:media, entity:unpublish_action:node, entity:unpublish_action:path_alias, entity:unpublish_action:taxonomy_term, entity:unpublish_action:menu_link_content
>  [error]  Update failed: fix_comment_delete_error_update_910002
 [error]  Update aborted by: fix_comment_delete_error_update_910002
 [error]  Finished performing updates.

We then stepped through all the code leading up to the original 'comment bulk delete' error using Xdebug, looking to see how the list of valid plugin IDs is generated. As far as we understand, it first makes a list of $base_plugin_definitions, which has a 'entity:delete_action'. It then searches for derivatives (like media, node and comment). For every derivative, it checks whether that derivative is applicable, by calling 'isApplicable()' (EntityDeleteActionDeriver.php); the isApplicable function then checks whether the entity has the link template 'delete-multiple-form'; which returns false for the comment type on our installation.

Can anyone give us pointers what to look for next? It's a Drupal 10 site that was updated from Drupal 9. Not sure when the error started, we only noticed it now.

Steps to reproduce

Content > Comments > select one or more comments using the checkbox > at the bottom of the page, select 'Action: Delete comment' > click 'Apply to selected items'.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

10.4

Component

comment.module

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ovquiaf
  • I agree this doesn't seem fundamentally different from #3045570: Plugin missing for node actions , so I am marking this a support request. All I can surmise is that there was a failed update along the way or perhaps someone imported an old configuration set, overwriting new required values, because the action is defined in core/modules/comment/config/install/system.action.comment_delete_action.yml.

    I would focus on the advice in comment 7 on [#3045570] . Does importing that configuration into the active configuration fix the problem?

  • Thanks for your reply @cilefen. We have tried the other suggestions from https://www.drupal.org/project/drupal/issues/3045570#comment-14111976:

    1. Configuration Update Manager: didn't show any relevant missing configuration items, but we made sure the list was empty anyway. Sadly no change
    2. Importing original system.action.comment_delete_action.yml: no changes except the langcode field. Import succeeded, didn't fix the error
    3. Configuration Update Manager: using 'Revert to source' function (when the langcode differs from source). Triggers the same PluginNotFoundException: The "entity:delete_action:comment" plugin does not exist.
    4. Configuration Update Manager: using 'Delete' function to remove system.action.comment_delete_action, then using 'Missing configuration items' to 'Import from source'. Also triggers the same PluginNotFoundException: The "entity:delete_action:comment" plugin does not exist.
    5. Importing a 'single item' config (using admin/config/development/configuration/single/import) for system.action.comment_delete_action, using the yml from source. Import works. But when bulk deleting a comment, still triggers the PluginNotFoundException

    Hope this helps to narrow it down?

  • Removed inaccuracy in the report; there is no other way to remove a single comment other than the 'bulk delete' form. I wrongfully described deleting the parent node as 'deleting the comment', but there deleting the comment is a side-effect.

  • We've been digging into this issue a bit more.

  • We only just noticed that the 'admin/content/comment' only has the 'Devel' button in the 'Operations' column, it's missing the 'Edit' and 'Delete' operations
  • The 'Delete comment' operation does appear in the bottom bar that appears as soon as you check a checkbox for a comment
  • If we delete the 'system.action.comment_delete_action' config using 'drush config:delete system.action.comment_delete_action', the 'delete' operation no longer appears in the bottom bar
  • If we then run 'drush config:import-missing system.action.comment_delete_action', we get the 'plugin does not exist' error:
    In DiscoveryTrait.php line 53:
    
      The "entity:delete_action:comment" plugin does not exist. Valid plugin IDs for Drupal\Core\Action\ActionManager are: node_assign_owner_action, node_unpublish_by_keyword_action, comment_unpu
      blish_by_keyword_action, node_make_sticky_action, node_promote_action, node_unpromote_action, node_make_unsticky_action, user_block_user_action, user_remove_role_action, user_add_role_actio
      n, user_unblock_user_action, user_cancel_user_action, entity:delete_action:media, entity:delete_action:node, action_message_action, entity:publish_action:block_content, entity:publish_actio
      n:comment, entity:publish_action:media, entity:publish_action:node, entity:publish_action:path_alias, entity:publish_action:taxonomy_term, entity:publish_action:menu_link_content, action_go
      to_action, action_send_email_action, entity:save_action:block_content, entity:save_action:comment, entity:save_action:file, entity:save_action:media, entity:save_action:node, entity:save_ac
      tion:taxonomy_term, entity:save_action:user, entity:save_action:menu_link_content, entity:unpublish_action:block_content, entity:unpublish_action:comment, entity:unpublish_action:media, ent
      ity:unpublish_action:node, entity:unpublish_action:path_alias, entity:unpublish_action:taxonomy_term, entity:unpublish_action:menu_link_content
    
    exit status 1
    Failed to run drush config:import-missing system.action.comment_delete_action: exit status 1
  • Same error if we use 'Configuration Updates Report' by clicking on the 'Import from source' option
  • If we import the original config from 'web/core/modules/comment/config/install/system.action.comment_delete_action.yml' using the single item import interface, it imports just fine, and the 'Delete comment' operation re-appears in the bottom bar again, however, the 'delete' and 'edit' options are still missing from the admin comments view at 'admin/content/comment'
  • Selecting 'Delete comment' and clicking 'Apply to selected items' still triggers the PluginNotFoundException
  • Updated title/body to better reflect the problem/scope of the issue

  • We narrowed it down to the 'comment fragment' module; uninstalling it gets rid of the error. This bug report can be closed, we filed a bug report with the module: https://www.drupal.org/project/comment_fragment/issues/3511710 🐛 Module breaks edit and delete links for comments Active

  • Production build 0.71.5 2024