Closed Bug 498635 Opened 17 years ago Closed 14 years ago

hooking format_comment()

Categories

(Bugzilla :: Extensions, enhancement)

3.2.2
enhancement
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: docwhat, Unassigned)

Details

I have an extension that needs to make a change to format_comment(). This can be done one of two ways: 1) Add a hook to format_comment(), perhaps 'bug-format_comment'. 2) Add a global hook so that anything can be monkey patched. Monkey patches aren't great, but they are very flexible. At the moment, my code looks like this: my $original_format_comment = \&Bugzilla::Bug::format_comment; *Bugzilla::Bug::format_comment = sub { my $comment = shift; if ($comment->{type} == CMT_REFERENCED) { return "*** bug ".$comment->{extra_data} ." references this bug ***"; # TODO: Use get_text() and global/messages.html.tmpl somehow... #return get_text('bug_referenced', { ref => $comment->{'extra_data'} }); } else { return $original_format_comment->($comment); } }; Either solution would work. Thanks. Ciao!
Option #1 is what we'd go with, for now. Eventually there will be a hooks system that allows you to subclass classes or add methods to them, but not now. FWIW, hooks are usually only likely to be added if the requester supplies a patch.
Severity: normal → enhancement
(In reply to comment #1) > FWIW, hooks are usually only likely to be added if the requester supplies a > patch. I didn't have a clue about what might be preferred or even if my 2 suggestions are even reasonable. :-)
Component: User Interface → Extensions
Assignee: ui → extensions
Isn't this covered by bug_format_comment hook?
Yeah, I think it is! :-) Thanks, rojanu. :-)
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.