function hook_node_update

Respond to updates to a node.

This hook is invoked from $node->save() after the database query that will update node in the node table is scheduled for execution, after the type-specific hook_update() is invoked, and after field_attach_update() is called.

Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and $node->save() goes out of scope. You should not rely on data in the database at this time as it is not updated yet. You should also note that any write/update database queries executed from this hook are also not committed immediately. Check $node->save() and db_transaction() for more info.

Parameters

\Drupal\Core\Entity\EntityInterface $node: The node that is being updated.

Related topics

11 functions implement hook_node_update()

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

book_node_update in drupal/core/modules/book/book.module
Implements hook_node_update().
entity_crud_hook_test_node_update in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_node_update().
forum_node_update in drupal/core/modules/forum/forum.module
Implements hook_node_update().
menu_node_update in drupal/core/modules/menu/menu.module
Implements hook_node_update().
node_access_test_node_update in drupal/core/modules/node/tests/modules/node_access_test/node_access_test.module
Implements hook_nodeapi_update().

... See full list

4 invocations of hook_node_update()
ConfigStorageController::save in drupal/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
Implements Drupal\Core\Entity\EntityStorageControllerInterface::save().
DatabaseStorageController::save in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
Implements \Drupal\Core\Entity\EntityStorageControllerInterface::save().
DatabaseStorageControllerNG::save in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
Overrides DatabaseStorageController::save().
MenuLinkStorageController::save in drupal/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php
Overrides DatabaseStorageController::save().

File

drupal/core/modules/node/node.api.php, line 701
Hooks provided by the Node module.

Code

function hook_node_update(\Drupal\Core\Entity\EntityInterface $node) {
  db_update('mytable')
    ->fields(array(
    'extra' => $node->extra,
  ))
    ->condition('nid', $node->nid)
    ->execute();
}