function nodereference_count_node_delete in Nodereference Count 7
Implements hook_node_delete().
hook_node_delete() runs before database queries are executed, so we cannot just update the counts here or it will reflect the count before anything has actually been deleted.
The workaround is an ugly hack. We add a delay flag to nodereference_count_references_update(). This allows us to add nids to a statically cached array instead of counting them immediately. The cached array can then be processed via hook_exit() after the database updates are done so that we get a correct count.
See also
nodereference_count_references_update().
nodereference_count_delayed_nids().
File
- ./
nodereference_count.module, line 262 - Defines a field type for counting the references to a node.
Code
function nodereference_count_node_delete($node) {
nodereference_count_references_update($node, TRUE);
}