No _send_hook_modify for body?
surge_martin - May 23, 2007 - 14:38
| Project: | Send |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | dww |
| Status: | needs review |
Description
It seems to me there's a typo in send.inc on line 605:
// let modules prepend / append stuff to the body, or otherwise modify it
$body = _send_hook_modify($body, 'node', $module, $node->type, $node);At this point in the function, it has just called _send_hook_modify in 'node' mode for each individual node. I notice, however, that nowhere is _send_hook_modify currently called in 'body' mode. I assumed that was the actual intention here, and changed line 605 as follows:
// let modules prepend / append stuff to the body, or otherwise modify it
$body = _send_hook_modify($body, 'body', $module, $node->type, $node);Now, it allows other modules to properly alter the overall body once all the nodes have been added.

#1
Yes, this is a bug. Here's an actual patch for this.
I'll be the first to admit, I've never seen anything in send that let's you send multiple nodes at a time. However, given that that appears to be what the module is trying to support in general, it seems a little weird to me that this 'body' hook is being invoked with the final node in the list. Seems like, if the body is supposed to be general, and not specific to any specific node, that this hook shouldn't get a $node object or node type. Doesn't make sense to me that it happens to get the *last* node, if there really are multiple nodes. So, I'm attaching another patch for consideration that invokes the body hook without the context of the final node.
Note: see also #257208: hook_send('node') invoked with wrong arguments, callback returned doesn't get info it needs which is related to this, but really a separate bug.