node.api.php documents hook_delete and hook_node_delete.
The documentation for hook_delete says
This hook is invoked from node_delete_multiple() after the node has been removed from the node table in the database, before hook_node_delete() is invoked, and before field_attach_delete() is called.
The documentation for hook_node_delete says
This hook is invoked from node_delete_multiple() after the type-specific hook_delete() has been invoked, but before hook_entity_delete and field_attach_delete() are called, and before the node is removed from the node table in the database.
So one claims the sequence
- Remove from node table in database
hook_delete
hook_node_delete
and the other claims the sequence
hook_delete
hook_node_delete
- Remove from node table in database
They can't both be correct unless some of those events happen twice.
Comments
Comment #1
jhodgdonThanks for the report! I think this page has the correct sequence (and I verified by looking at node_delete_multiple()):
https://api.drupal.org/api/drupal/modules!node!node.api.php/group/node_a...
This is a Drupal 7 issue only.
Comment #2
valderama commentedAs far as I understand the db transaction is committed when the scope leaves node_delete_multiple(). Which means that the node is deleted from the database at the end, after all hook calls.
Also, the page referenced by jhodgdon documents it that way.
I'll prepare a patch which reflects this behavior.
Comment #3
valderama commentedI have updated the documentation and added an additional paragraph with further clarification about the db_transaction. I took this paragraph from this issue, which was about node_save:
https://drupal.org/node/1677830
Comment #4
jhodgdonThanks! The documentation looks good, but the patch needs some work -- there are a lot of spaces at the ends of lines that need to be removed.
You should be able to set up your programming editor to remove and/or highlight end-of-line spaces.
Comment #5
valderama commentedAlright, found the setting in netbeans which removes trailing whitespace on save :)
Here is a new patch...
Comment #6
jhodgdonThat's better! Now just take the changes to .gitignore out of the patch. :)
Comment #7
valderama commentedOh, I did not realize that these changes came into the patch too. Sorry.
How does this patch look now?
Comment #8
jhodgdonGreat, thanks!
My suggestion: Always do "git status" to see what you've changed before doing "git diff". Then if you want to get only some of the changes into the diff/patch, you can do something like "git diff modules" to get, for instance, just the changes in the modules directory and its subdirectories.
I was just getting set up to make some commits, so I committed this to 7.x.
Comment #10
jhodgdonIgnore the test failures. The patches won't apply because they've been committed. I should have waited to commit until the tests ran, but since it was a docs-only patch, I didn't. My bad...
Comment #12
jhodgdon