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:

  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.

#1

swentel - January 10, 2009 - 20:01

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

Jody Lynn - January 29, 2009 - 19:39

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

#3

bradfordcp - April 17, 2009 - 06:25

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)
AttachmentSizeStatusTest resultOperations
node-355905-3.patch14.45 KBIdleFailed: Failed to apply patch.View details | Re-test

#4

bradfordcp - April 17, 2009 - 06:07
Assigned to:Anonymous» bradfordcp
Status:active» needs review

For some reason the status did not change...

#5

System Message - April 26, 2009 - 11:10
Status:needs review» needs work

The last submitted patch failed testing.

#6

Jody Lynn - July 5, 2009 - 19:11
Status:needs work» duplicate

node_delete_multiple has landed: #457080: Add node_delete_multiple()

 
 

Drupal is a registered trademark of Dries Buytaert.