Download & Extend

node_delete_multiple() has to use batch API

Project:Drupal core
Version:7.x-dev
Component:node system
Category:bug report
Priority:critical
Assigned:bradfordcp
Status:closed (duplicate)

Issue Summary

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.

Comments

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

  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

Assigned to:Anonymous» bradfordcp
Status:active» needs review

For some reason the status did not change...

#5

Status:needs review» needs work

The last submitted patch failed testing.

#6

Status:needs work» closed (duplicate)

node_delete_multiple has landed: #457080: Add node_delete_multiple()

#7

#8

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

#9

Status:active» closed (duplicate)

Patch here #89181: Use queue API for node and comment, user, node multiple deletes.