From 5aba1b12a34c1fde3a99b3db781dbae3f0d1259f Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Thu, 29 May 2008 03:43:33 +0000 Subject: Bug 318205: The path to the hook is incorrect when called from inside a block Patch By Elliotte Martin r=mkanat, a=mkanat --- Bugzilla/Template/Plugin/Hook.pm | 63 +++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) (limited to 'Bugzilla/Template/Plugin') diff --git a/Bugzilla/Template/Plugin/Hook.pm b/Bugzilla/Template/Plugin/Hook.pm index 4e3bf5cef..05a1fdfd1 100644 --- a/Bugzilla/Template/Plugin/Hook.pm +++ b/Bugzilla/Template/Plugin/Hook.pm @@ -19,6 +19,7 @@ # # Contributor(s): Myk Melez # Zach Lipton +# Elliotte Martin # package Bugzilla::Template::Plugin::Hook; @@ -45,12 +46,11 @@ sub new { } sub process { - my ($self, $hook_name) = @_; + my ($self, $hook_name, $template) = @_; + $template ||= $self->{_CONTEXT}->stash->{component}->{name}; + + my @hooks; - my $paths = $self->{_CONTEXT}->{LOAD_TEMPLATES}->[0]->paths; - my $template = $self->{_CONTEXT}->stash->{component}->{name}; - my @hooks = (); - # sanity check: if (!$template =~ /[\w\.\/\-_\\]+/) { ThrowCodeError('template_invalid', { name => $template}); @@ -79,6 +79,8 @@ sub process { } } } + + my $paths = $self->{_CONTEXT}->{LOAD_TEMPLATES}->[0]->paths; # we keep this too since you can still put hook templates in # template/en/custom/hook @@ -116,9 +118,54 @@ Bugzilla::Template::Plugin::Hook Template Toolkit plugin to process hooks added into templates by extensions. +=head1 METHODS + +=over + +=item B + +=over + +=item B + +Processes hooks added into templates by extensions. + +=item B + +=over + +=item C + +The unique name of the template hook. + +=item C