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

dgtlmoon’s picture

see http://drupal.org/node/214004 for a module that implements just this

dpearcefl’s picture

Status: Active » Closed (won't fix)

Considering the time elapsed between now and the last comment plus the fact that D5 is no longer supported, I am closing this ticket.