diff options
author | Jennifer Hodgdon <yahgrp@poplarware.com> | 2012-10-09 10:31:58 -0700 |
---|---|---|
committer | Jennifer Hodgdon <yahgrp@poplarware.com> | 2012-10-09 10:31:58 -0700 |
commit | a202c699e0416c39f6da45c65df93a1447a1cc88 (patch) | |
tree | 98c9bc58173fae2a87c1d816d1ad5c47fa532c35 | |
parent | 994b2b3d4b8bf093541d0e61f456110b19fda677 (diff) | |
download | brdo-a202c699e0416c39f6da45c65df93a1447a1cc88.tar.gz brdo-a202c699e0416c39f6da45c65df93a1447a1cc88.tar.bz2 |
Issue #1677830 by slashrsm: Improve docs for user and node hooks in regards to database transactions
-rw-r--r-- | modules/node/node.api.php | 30 | ||||
-rw-r--r-- | modules/user/user.api.php | 16 |
2 files changed, 40 insertions, 6 deletions
diff --git a/modules/node/node.api.php b/modules/node/node.api.php index 87194576f..052effc9b 100644 --- a/modules/node/node.api.php +++ b/modules/node/node.api.php @@ -498,9 +498,18 @@ function hook_node_revision_delete($node) { /** * Respond to creation of a new node. * - * This hook is invoked from node_save() after the node is inserted into the - * node table in the database, after the type-specific hook_insert() is invoked, - * and after field_attach_insert() is called. + * This hook is invoked from node_save() after the database query that will + * insert the node into the node table is scheduled for execution, after the + * type-specific hook_insert() is invoked, and after field_attach_insert() 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. * * @param $node * The node that is being created. @@ -687,9 +696,18 @@ function hook_node_presave($node) { /** * Respond to updates to a node. * - * This hook is invoked from node_save() after the node is updated in the node - * table in the database, after the type-specific hook_update() is invoked, and - * after field_attach_update() is called. + * 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. * * @param $node * The node that is being updated. diff --git a/modules/user/user.api.php b/modules/user/user.api.php index f610408dc..64c863fe4 100644 --- a/modules/user/user.api.php +++ b/modules/user/user.api.php @@ -299,6 +299,14 @@ function hook_user_login(&$edit, $account) { /** * The user just logged out. * + * 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 user_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 user_save() and db_transaction() for more info. + * * @param $account * The user object on which the operation was just performed. */ @@ -317,6 +325,14 @@ function hook_user_logout($account) { * The module should format its custom additions for display and add them to the * $account->content array. * + * 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 user_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 user_save() and db_transaction() for more info. + * * @param $account * The user object on which the operation is being performed. * @param $view_mode |