hook_send('node') invoked with wrong arguments, callback returned doesn't get info it needs
| Project: | Send |
| Version: | 5.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | dww |
| Status: | duplicate |
Jump to:
I've been digging into hook_send(), trying to implement my own send functionality in a custom module for a site. I noticed a few problems with hook_send('node'), where the module is supposed to get a chance to modify the node body that's included in the email.
A) The first problem is that in my testing, $node is always NULL inside hook_send('node'). After a little debugging, I see why. When that hook is being invoked, the module name isn't being included in the argument list, so the args to the hook aren't what the hook implementation is expecting. Trivial patch attached for this ("hook_send_node_arg_mismatch.d5.patch").
B) The second problem is that the architecture of this hook is a little counter-intuitive. The hook is invoked (once the first patch is applied) with all the relevant context to be able to modify the text (in particular, the $node object). However, the hook is only supposed to return a callback function which does the modifying. And *that* function gets no context at all, just the text it's trying to modify. I propose that we invoke this 2nd callback function with both the current text and the $node object so that the callback can do fancy stuff based on what's in the $node. I'll admit that's an API change, but I really don't see how this callback stuff is useful in its current state, so I can't imagine anyone would mind if a 2nd argument started showing up that gave them the context they need to do good things. See the other patch ("hook_send_node_callback_gets_node.d5.patch").
Note: this is all separate from #146301: No _send_hook_modify for body?, which is also a bug.
| Attachment | Size |
|---|---|
| hook_send_node_arg_mismatch.d5.patch | 743 bytes |
| hook_send_node_callback_gets_node.d5.patch | 834 bytes |

#1
Whoops, I just noticed #166980: Bugs with hook_send $op='node' is older and about the same bug. Let's move discussion there.