function node_delete_multiple

Deletes multiple nodes.


$nids: An array of node IDs.

4 calls to node_delete_multiple()
BookTestCase::testBookDelete in modules/book/book.test
Tests the access for deleting top-level book nodes.
node_delete in modules/node/node.module
Deletes a node.
node_multiple_delete_confirm_submit in modules/node/
Form submission handler for node_multiple_delete_confirm().
node_user_delete in modules/node/node.module
Implements hook_user_delete().


modules/node/node.module, line 1244


function node_delete_multiple($nids) {
    $transaction = db_transaction();
    if (!empty($nids)) {
        $nodes = node_load_multiple($nids, array());
        try {
            foreach ($nodes as $nid => $node) {
                // Call the node-specific callback (if any):
                node_invoke($node, 'delete');
                module_invoke_all('node_delete', $node);
                module_invoke_all('entity_delete', $node, 'node');
                field_attach_delete('node', $node);
                // Remove this node from the search index if needed.
                // This code is implemented in node module rather than in search module,
                // because node module is implementing search module's API, not the other
                // way around.
                if (module_exists('search')) {
                    search_reindex($nid, 'node');
            // Delete after calling hooks so that they can query node tables as needed.
            db_delete('node')->condition('nid', $nids, 'IN')
            db_delete('node_revision')->condition('nid', $nids, 'IN')
            db_delete('history')->condition('nid', $nids, 'IN')
            db_delete('node_access')->condition('nid', $nids, 'IN')
        } catch (Exception $e) {
            watchdog_exception('node', $e);
            throw $e;
        // Clear the page and block and node_load_multiple caches.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.