Closed (won't fix)
Project:
Drupal core
Version:
5.x-dev
Component:
comment.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Jan 2008 at 03:34 UTC
Updated:
21 Jun 2011 at 23:34 UTC
the comment.module hands you an object but expects you to return an array of changes, but these changes (like i mention above) are never processed back into the comment output unless you modify the object in the reference (so whats the point of being asked to return an array?)
/**
* Invoke a hook_comment() operation in all modules.
*
* @param &$comment
* A comment object.
* @param $op
* A string containing the name of the comment operation.
* @return
* The returned value of the invoked hooks.
*/
function comment_invoke_comment(&$comment, $op) {
$return = array();
foreach (module_implements('comment') as $name) {
$function = $name .'_comment';
$result = $function($comment, $op);
if (isset($result) && is_array($result)) {
$return = array_merge($return, $result);
}
else if (isset($result)) {
$return[] = $result;
}
}
return $return;
}
So if you have a module which implements hook_comment to change the comment 'body' then by simply returning the $comment['comment']="replacement"; it will fail, however if you specify my_module(&$comment) as reference then it will work but $comment is an object - i think this is all a little inconsistent? thoughts?
Comments
Comment #1
dgtlmoon commentedsee http://drupal.org/node/214004 for a module that implements just this
Comment #2
dpearcefl commentedConsidering the time elapsed between now and the last comment plus the fact that D5 is no longer supported, I am closing this ticket.