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:

  1. Introduce a node_mass_delete() function, using almost the same pattern as node_mass_update() - most probably leading to almost identical/duplicated code.
  2. Make node_mass_update() more flexible, f.e. passing array('nid' => NULL) can only mean that nodes shall be deleted.
CommentFileSizeAuthor
#3 node-355905-3.patch14.45 KBbradfordcp
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

swentel’s picture

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 :)

Jody Lynn’s picture

Batch delete would also be useful to this issue: #362795: Delete Entire Book

bradfordcp’s picture

Assigned: bradfordcp » Unassigned
Status: Needs review » Active
FileSize
14.45 KB

This is a first attempt at creating a new mass_operation function for nodes. To summarize the patch:

  1. Moved node_mass_update() from node.admin.inc into node.module (since this is / may be used outside of the administration page)
  2. Changed method signature to: node_mass_operation($nodes, $op, $updates = array() This provided the flexibility needed to allow mass delete operations
  3. Renamed and updated the appropriate helper methods that go along with performing the operations and utilizing batch API
  4. Updated the appropriate form submission handlers to utilize the new method (these were within node and user module)
bradfordcp’s picture

Assigned: Unassigned » bradfordcp
Status: Active » Needs review

For some reason the status did not change...

Assigned: Unassigned » bradfordcp
Status: Active » Needs work

The last submitted patch failed testing.

Jody Lynn’s picture

Status: Needs work » Closed (duplicate)

node_delete_multiple has landed: #457080: Add node_delete_multiple()

sun’s picture

sun’s picture

Title: Missing node_mass_delete() or make node_mass_update() more flexible » node_delete_multiple() has to use batch API
catch’s picture

Status: Active » Closed (duplicate)