Missing node_mass_delete() or make node_mass_update() more flexible
sun - January 8, 2009 - 06:33
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | node system |
| Category: | bug report |
| Priority: | critical |
| Assigned: | bradfordcp |
| Status: | duplicate |
Description
While working on #8: Let users cancel their accounts, I discovered that we have node_mass_update() for updating many nodes in a batch, but no node_mass_delete() for deleting many nodes in a batch.
Aside from the fact that an administrator can delete many nodes using the node mass-operations on admin/content/node, the new account cancellation methods also allow administrators to delete all contents of a user. When an administrator is forced to delete a long-time user with all of his contents, then this could easily result in thousands of nodes having to be deleted.
We have two options to solve this issue:
- Introduce a node_mass_delete() function, using almost the same pattern as node_mass_update() - most probably leading to almost identical/duplicated code.
- Make node_mass_update() more flexible, f.e. passing
array('nid' => NULL)can only mean that nodes shall be deleted.

#1
I somehow see a third option: rename node_mass_update and _node_mass_update_helper to a more general name, because with few small code changes it should be possible to either create, update or delete a node with only one function. Saves kittens imo :)
#2
Batch delete would also be useful to this issue: #362795: Delete Entire Book
#3
This is a first attempt at creating a new mass_operation function for nodes. To summarize the patch:
node_mass_operation($nodes, $op, $updates = array()This provided the flexibility needed to allow mass delete operations#4
For some reason the status did not change...
#5
The last submitted patch failed testing.
#6
node_delete_multiple has landed: #457080: Add node_delete_multiple()