Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
hook_user
hook_block
hook_menu
hook_nodeapi
hook_schema
hook_taxonomy
Which of these things doesn't belong? :P What on earth is a "nodeapi"?
This trips up lots of new developers and also makes our API look sloppy. IMO we should change nodeapi to node.
Comment | File | Size | Author |
---|---|---|---|
#1 | no_nodeapi.patch | 61.72 KB | David Strauss |
Comments
Comment #1
David StraussComment #2
David StraussComment #3
mfer CreditAttribution: mfer commentedUnder orders to say "hell yeah".
Comment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedThat's so cool (@webchick).
Comment #5
Crell CreditAttribution: Crell commentedAmen and pass the sweet potatoes!
Comment #6
webchickYAY!!! :D This patch powered by delicious melted ice cream.
Needs documenting.
Comment #7
David StraussHere's what should be added to http://drupal.org/node/224333
Comment #8
stella CreditAttribution: stella commentedLooks like you also need to add in a bit about
node_invoke_nodeapi()
being renamed tonode_invoke_node()
Comment #9
XanoI advise against this. We need to rename hooks like hook_load() to hook_node_load(), since hook names start with the name of the module that introduces them, and this patch would conflict with that.
Comment #10
stella CreditAttribution: stella commented@Xano this is already committed
Comment #11
XanoMy bad, but my advise still stands. Hook_load(), hook_form(), etc. are confusing and make the API even more sloppy. If we change them to hook_node_load(), etc., we need to think of al alternative for hook_nodeapi_X().
Comment #12
Damien Tournoud CreditAttribution: Damien Tournoud commented@Xano: *_load(), *_form(), etc. are not really hooks as there are not called by module_invoke_all(). There are a rather dumb implementation of a strategy pattern. We need a better system for D7, for sure (probably based on some DrupalNodeType interface), renaming *_load() to *_node_load() would only add to the confusion.
See #395786: Move node-type callbacks to a proper interface.
Comment #13
David StraussWith Damien's issue #395786, I'm setting this back to CNW for documentation.
Comment #14
webchickComment #15
webchickEr. I didn't mean to do that.
Comment #16
webchickAlso, I agree with Damien that the pseudo-hooks _load, _insert, etc. are their own thing and should be dealt with separately. Maybe by turning them OO as in #395786: Move node-type callbacks to a proper interface but that's for discussion over there. :)
But hook_user_X, hook_file_X, etc. all match the pattern of "Someone else defined this thing, and now my module wants to act on it." So hook_node_X is a good fit here.
Comment #17
rfayI added this into the docs at http://drupal.org/update/modules/6/7#hook_node_xxx
I attempted to update all previous references (now outdated) to hook_nodeapi_xxx() as well.