4.6.x node.php hook_update($node)
4.7.x node.php hook_update($node)
5.x node.php hook_update($node)
6.x node.php hook_update($node)
7.x node.api.php hook_update($node)

Respond to updates to a node.

This is a node-type-specific hook, which is invoked only for the node type being affected. See Node API hooks for more information.

Use hook_node_update() to respond to node update of all node types.

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

48 functions implement hook_update()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

book_form_update in modules/book/book.module
Renders a new parent page select element when the book selection changes.
book_node_type_update in modules/book/book.module
Implements hook_node_type_update().
book_node_update in modules/book/book.module
Implements hook_node_update().
comment_node_type_update in modules/comment/comment.module
Implements hook_node_type_update().
dashboard_update in modules/dashboard/dashboard.module
Sets the new weight of each region according to the drag-and-drop order.

... See full list

3 invocations of hook_update()
field_attach_update in modules/field/field.attach.inc
Save field data for an existing entity.
update_check_requirements in ./update.php
Checks update requirements and reports errors and (optionally) warnings.
user_save in modules/user/user.module
Save changes to a user account or add a new user.

File

modules/node/node.api.php, line 1236
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

pivanov’s picture

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.

deltahex’s picture

yeah. it is mentioned in the hook_node_update documentation and is visible in the node_save() function code but still makes a lot of confusion especially if you are reading the comments... :) The transaction manual is giving some answers...

gollyg’s picture

Looking for the function documentation for applying a module update hook? Head over to hook_update_N