hook_update

5 node.php hook_update($node)
6 node.php hook_update($node)
7 node.api.php hook_update($node)
8 node.api.php hook_update(Drupal node Node $node)

Respond to updates to a node.

This hook is invoked only on the module that defines the node's content type (use hook_node_update() to act on all node updates).

This hook is invoked from node_save() after the node is updated in the node table in the database, before field_attach_update() is called, and before hook_node_update() is invoked.

Parameters

$node: The node that is being updated.

Related topics

64 functions implement hook_update()

3 invocations of hook_update()

File

modules/node/node.api.php, line 1193
Hooks provided by the Node module.

Code

function hook_update($node) {
  db_update('mytable')
    ->fields(array('extra' => $node->extra))
    ->condition('nid', $node->nid)
    ->execute();
}

Comments

{node} table not actually updated!

hook_update gets invoked from within node_save(), which actually is wrapped in a transaction! Therefore the {node} table is not updated when hook_update is called. Don't query the table or, especially, don't call functions that rely on {node} table.

Login or register to post comments