Drupal features a ton of useful hooks, but not all of them are actual hooks:

  • hook_insert()
  • hook_update()
  • hook_delete()
  • hook_validate()
  • hook_view()
  • hook_load()
  • hook_install()
  • hook_uninstall()
  • hook_enable()
  • hook_disable()
  • hook_form()
  • hook_schema() (possibly)

These are callbacks that are the only ones to respond to a certain event. In the case of hook_load() (and siblings) versus hook_nodeapi() this becomes confusing for a lot of newcomers, because they think that since all of them are hooks, all of them can be used to hook into node manipulation.

We should make clear these functions are not hooks and do not work the same way.

Comments

damien tournoud’s picture

See #395786: Move node-type callbacks to a proper interface for the node type callbacks.

The five "modules" pseudo-hooks can probably stay as is:

# hook_install()
# hook_uninstall()
# hook_enable()
# hook_disable()
# hook_schema()

After all, mymodule_install() is the implementation of the specific "install" method of "mymodule", which makes more sense then "mymodule_load" which is the implementation of the "load" method of one of the node types defined by "mymodule".

xano’s picture

I see I haven't been clear enough, my apologies. It is not my intention to change the way these pseudo-hooks/callbacks are implemented, but to make clear that they are not regular hooks. A solution could be to simply call them callbacks and refer to them as callback_install().

xano’s picture

Component: base system » documentation
jhodgdon’s picture

Status: Active » Closed (works as designed)

I believe that in D7, all of these hooks are well documented, in that they clearly state things like this:
http://api.drupal.org/api/function/hook_load/7
This hook is invoked only on the module that defines the node's content type (use hook_node_load() to respond to all node loads).

I agree that they are not "hooks" in the sense that they are called for all modules, but we don't really have a better term for them. They aren't going to change names in D7, it's much too late for that...

So we could move this to D6 to fix the docs there (and I think if so it's a duplicate of another issue, where we fixed up the D7 docs and it hasn't been ported to D6 yet), or to D8 to consider renaming them. I'll leave it up to you... But my preference is to mark this "works as designed" for now.