I've been trying to find an efficient back-end way to delete large numbers of nodes based on some filter criteria to implement data retention policies. I have read that it's possible to perform actions provided by views bulk operations on results from a view via drush - such as in the answer in the screenshot below (in response to this question).

enter image description here

This seems like a very powerful concept because you can use the selection power of views and do operations on large amounts of data from the server side. I tried to do this on my Drupal 9 site. One discrepancy I noticed is that when I go to add the VBO field, I do not have an option for "Bulk Operations: Content" like is suggested in the above screenshot, rather only the one from the "Global" Category:

enter image description here

I tried using that field anyway, and selected the "Delete selected entities/translations" option and saved the view.

When I try to execute the action from the view using the drush command
drush vbo-execute my_view_id action::views_bulk_operations_delete_item

I get the following error:

In ViewsBulkOperationsActionManager.php line 169:

  The "action::delete_action" plugin does not exist.

I cannot seem to find this error in any other forum posts, or any documentation from VBO as to how to identify what actions are available. Is this capability for VBO not available for Drupal 9, or is there some knowledge base I have missed that details how to specify the action?


After much searching to no avail, I decided to dig into the VBO codebase. It turns out that I was using the wrong action id (the 2nd argument to the drush command after the view id). Whatever action id was being used in the post I referenced is not the right one (either it was custom or VBO has since changed the convention for action id's). I discovered this by finding the file that implemented the action (delete) that I wanted, which happened to be in /drupal_root/modules/contrib/views_bulk_operations/src/Plugin/Action/EntityDeleteAction.php. This file has an annotation block that specifies the action id to use:

namespace Drupal\views_bulk_operations\Plugin\Action;

use Drupal\views_bulk_operations\Action\ViewsBulkOperationsActionBase;
use Drupal\Core\Entity\TranslatableInterface;
use Drupal\Core\Session\AccountInterface;

 * Delete entity action with default confirmation form.
 * @Action(
 *   id = "views_bulk_operations_delete_entity",
 *   label = @Translation("Delete selected entities / translations"),
 *   type = "",
 *   confirm = TRUE,
 * )
class EntityDeleteAction extends ViewsBulkOperationsActionBase {

running drush vbo-execute my_delete_view views_bulk_operations_delete_entity did the trick! No idea why there doesn't appear to be any documentation about this (at least that I can find), but I'm glad I finally figured it out and hopefully this helps someone else having the same trouble.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.