Community Documentation

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($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

▾ 106 functions implement hook_update()

BasicMinimalUpdatePath::testBasicMinimalUpdate in modules/simpletest/tests/upgrade/upgrade.test
Tests a successful point release update.
BasicStandardUpdatePath::testBasicStandardUpdate in modules/simpletest/tests/upgrade/upgrade.test
Tests a successful point release update.
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
Set the new weight of each region according to the drag-and-drop order.
DatabaseConnection::update in includes/database/database.inc
Prepares and returns an UPDATE query object.
DatabaseMergeTestCase::testMergeInsertWithoutUpdate in modules/simpletest/tests/database_test.test
Test that we can merge-insert without any update fields.
DatabaseMergeTestCase::testMergeUpdate in modules/simpletest/tests/database_test.test
Confirm that we can merge-update a record successfully.
DatabaseMergeTestCase::testMergeUpdateWithoutUpdate in modules/simpletest/tests/database_test.test
Confirm that we can merge-update without any update fields.
DatabaseUpdateComplexTestCase::testBetweenConditionUpdate in modules/simpletest/tests/database_test.test
Test BETWEEN conditional clauses.
DatabaseUpdateComplexTestCase::testInConditionUpdate in modules/simpletest/tests/database_test.test
Test WHERE IN clauses.
DatabaseUpdateComplexTestCase::testLikeConditionUpdate in modules/simpletest/tests/database_test.test
Test LIKE conditionals.
DatabaseUpdateComplexTestCase::testNotInConditionUpdate in modules/simpletest/tests/database_test.test
Test WHERE NOT IN clauses.
DatabaseUpdateComplexTestCase::testOrConditionUpdate in modules/simpletest/tests/database_test.test
Test updates with OR conditionals.
DatabaseUpdateTestCase::testExpressionUpdate in modules/simpletest/tests/database_test.test
Test updating with expressions.
DatabaseUpdateTestCase::testMultiGTUpdate in modules/simpletest/tests/database_test.test
Confirm that we can update a multiple records with a non-equality condition.
DatabaseUpdateTestCase::testMultiUpdate in modules/simpletest/tests/database_test.test
Confirm that we can update a multiple records successfully.
DatabaseUpdateTestCase::testSimpleNullUpdate in modules/simpletest/tests/database_test.test
Confirm updating to NULL.
DatabaseUpdateTestCase::testSimpleUpdate in modules/simpletest/tests/database_test.test
Confirm that we can update a single record successfully.
DatabaseUpdateTestCase::testWhereAndConditionUpdate in modules/simpletest/tests/database_test.test
Confirm that we can stack condition and where calls.
DatabaseUpdateTestCase::testWhereUpdate in modules/simpletest/tests/database_test.test
Confirm that we can update a multiple records with a where call.
DBLogTestCase::getContentUpdate in modules/dblog/dblog.test
Create content update based on content type.
db_update in includes/database/database.inc
Returns a new UpdateQuery object for the active database.
DrupalUpdaterInterface::postUpdate in includes/updater.inc
Actions to run after an update has occurred.
entity_crud_hook_test_comment_update in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_comment_update().
entity_crud_hook_test_entity_update in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_entity_update().
entity_crud_hook_test_file_update in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_file_update().
entity_crud_hook_test_node_update in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_node_update().
entity_crud_hook_test_taxonomy_term_update in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_taxonomy_term_update().
entity_crud_hook_test_taxonomy_vocabulary_update in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_taxonomy_vocabulary_update().
entity_crud_hook_test_user_update in modules/simpletest/tests/entity_crud_hook_test.module
Implements hook_user_update().
FieldSqlStorageTestCase::testFieldAttachInsertAndUpdate in modules/field/modules/field_sql_storage/field_sql_storage.test
Reads mysql to verify correct data is written when using insert and update.
field_attach_update in modules/field/field.attach.inc
Save field data for an existing entity.
FIELD_STORAGE_UPDATE in modules/field/field.attach.inc
Argument for an update operation.
field_test_field_update in modules/field/tests/field_test.field.inc
Implements hook_field_update().
file_field_update in modules/file/file.field.inc
Implements hook_field_update().
file_test_file_update in modules/simpletest/tests/file_test.module
Implements hook_file_update().
FilledMinimalUpdatePath::testFilledStandardUpdate in modules/simpletest/tests/upgrade/upgrade.test
Tests a successful point release update.
FilledStandardUpdatePath::testFilledStandardUpdate in modules/simpletest/tests/upgrade/upgrade.test
Tests a successful point release update.
filter_test_filter_format_update in modules/simpletest/tests/filter_test.module
Implements hook_filter_format_update().
forum_comment_update in modules/forum/forum.module
Implements hook_comment_update().
forum_field_storage_pre_update in modules/forum/forum.module
Implements hook_field_storage_pre_update().
forum_node_update in modules/forum/forum.module
Implements hook_node_update().
hook_comment_update in modules/comment/comment.api.php
The comment is being updated.
hook_entity_update in modules/system/system.api.php
Act on entities when updated.
hook_field_attach_update in modules/field/field.api.php
Act on field_attach_update().
hook_field_storage_pre_update in modules/field/field.api.php
Act before the storage backends update field data.
hook_field_update in modules/field/field.api.php
Define custom update behavior for this module's field types.
hook_file_update in modules/system/system.api.php
Respond to a file being updated.
hook_filter_format_update in modules/filter/filter.api.php
Perform actions when a text format has been updated.
hook_menu_link_update in modules/system/system.api.php
Inform modules that a menu link has been updated.
hook_menu_update in modules/menu/menu.api.php
Informs modules that a custom menu was updated.
hook_node_type_update in modules/node/node.api.php
Respond to node type updates.
hook_node_update in modules/node/node.api.php
Respond to updates to a node.
hook_path_update in modules/path/path.api.php
Allow modules to respond to a path being updated.
hook_taxonomy_term_update in modules/taxonomy/taxonomy.api.php
Act on taxonomy terms when updated.
hook_taxonomy_vocabulary_update in modules/taxonomy/taxonomy.api.php
Act on taxonomy vocabularies when updated.
hook_user_role_update in modules/user/user.api.php
Inform other modules that a user role has been updated.
hook_user_update in modules/user/user.api.php
A user account was updated.
image_field_update in modules/image/image.field.inc
Implements hook_field_update().
LocaleLanguageNegotiationInfoFunctionalTest::languageNegotiationUpdate in modules/locale/locale.test
Update language types/negotiation information.
locale_system_update in modules/locale/locale.module
Imports translations when new modules or themes are installed.
menu_node_update in modules/menu/menu.module
Implements hook_node_update().
menu_test_menu_link_update in modules/simpletest/tests/menu_test.module
Implements hook_menu_link_update().
MergeQuery::$needsUpdate in includes/database/query.inc
Flag indicating whether an UPDATE is necessary.
MergeQuery::STATUS_UPDATE in includes/database/query.inc
Returned by execute() if an UPDATE query has been executed.
ModuleUpdater::canUpdate in modules/system/system.updater.inc
node_access_test_node_update in modules/node/tests/node_access_test.module
Implements hook_nodeapi_update().
node_mass_update in modules/node/node.admin.inc
Make mass update of nodes, changing all nodes in the $nodes array to update them with the field values in $updates.
node_node_type_update in modules/node/content_types.inc
Implements hook_node_type_update().
node_test_node_update in modules/node/tests/node_test.module
Implements hook_node_update().
path_node_update in modules/path/path.module
Implements hook_node_update().
path_taxonomy_term_update in modules/path/path.module
Implements hook_taxonomy_term_update().
PollTestCase::pollUpdate in modules/poll/poll.test
poll_update in modules/poll/poll.module
Implements hook_update().
registry_update in includes/bootstrap.inc
Updates the registry based on the latest files listed in the database.
search_comment_update in modules/search/search.module
Implements hook_comment_update().
search_node_update in modules/search/search.module
Implements hook_node_update().
SelectQuery::$forUpdate in includes/database/select.inc
The FOR UPDATE status
SelectQuery::forUpdate in includes/database/select.inc
Add FOR UPDATE to the query.
SelectQueryExtender::forUpdate in includes/database/select.inc
Add FOR UPDATE to the query.
SelectQueryInterface::forUpdate in includes/database/select.inc
Add FOR UPDATE to the query.
SelectQuery_sqlite::forUpdate in includes/database/sqlite/select.inc
Add FOR UPDATE to the query.
taxonomy_node_update in modules/taxonomy/taxonomy.module
Implements hook_node_update().
taxonomy_taxonomy_vocabulary_update in modules/taxonomy/taxonomy.module
Implements hook_taxonomy_vocabulary_update().
taxonomy_test_taxonomy_term_update in modules/simpletest/tests/taxonomy_test.module
Implements hook_taxonomy_term_update().
text_filter_format_update in modules/field/modules/text/text.module
Implements hook_filter_format_update().
ThemeUpdater::canUpdate in modules/system/system.updater.inc
tracker_comment_update in modules/tracker/tracker.module
Implements hook_comment_update().
tracker_node_update in modules/tracker/tracker.module
Implements hook_node_update().
translation_node_update in modules/translation/translation.module
Implements hook_node_update().
trigger_comment_update in modules/trigger/trigger.module
Implements hook_comment_update().
trigger_node_update in modules/trigger/trigger.module
Implements hook_node_update().
trigger_taxonomy_term_update in modules/trigger/trigger.module
Implements hook_taxonomy_term_update().
trigger_user_update in modules/trigger/trigger.module
Implements hook_user_update().
Update manager: update in modules/update/update.manager.inc
Update manager for updating existing code.
UpdateCoreTestCase::testModulePageRegularUpdate in modules/update/update.test
Check the messages at admin/modules when missing an update.
UpdateCoreTestCase::testModulePageSecurityUpdate in modules/update/update.test
Check the messages at admin/modules when missing a security update.
UpdateDependencyMissingTestCase::testMissingUpdate in modules/simpletest/tests/update.test
Updater::postUpdate in includes/updater.inc
Perform actions after new code is updated.
Updater::update in includes/updater.inc
Updates a Drupal project, returns a list of next actions.
UpdateTestContribCase::testUpdateBaseThemeSecurityUpdate in modules/update/update.test
Test that subthemes are notified about security updates for base themes.
update_authorize_run_update in modules/update/update.authorize.inc
Callback invoked by authorize.php to update existing projects.
_registry_update in includes/registry.inc
Does the work for registry_update().

File

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

Code

<?php
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