diff options
author | Dylan William Hardison <dylan@hardison.net> | 2017-04-01 16:45:25 +0200 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2017-04-10 17:40:13 +0200 |
commit | ecbdca8c3f06dd420db6a960c8808615dae6848a (patch) | |
tree | 14fc2b6ae0adbafa8df2e4982b22fe41f0b36d22 /Bugzilla/Template | |
parent | 7d6ee3486e6a76ed0c96341d184c20ae09de2019 (diff) | |
download | bugzilla-ecbdca8c3f06dd420db6a960c8808615dae6848a.tar.gz bugzilla-ecbdca8c3f06dd420db6a960c8808615dae6848a.tar.xz |
Bug 1352913 - Extensions must register for template_before_process()
We can skip a lot of method calls if extensions must declare what
templates they act on.
Diffstat (limited to 'Bugzilla/Template')
-rw-r--r-- | Bugzilla/Template/Context.pm | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/Bugzilla/Template/Context.pm b/Bugzilla/Template/Context.pm index b81e32130..e78cd9806 100644 --- a/Bugzilla/Template/Context.pm +++ b/Bugzilla/Template/Context.pm @@ -69,13 +69,24 @@ sub stash { # template object for Throw*Error). # # Checking Bugzilla::Hook::in prevents infinite recursion on this hook. - if ($self->{bz_in_process} and $name =~ /\./ - and !grep($_ eq $name, @$pre_process) - and !Bugzilla::Hook::in('template_before_process')) + + if ( $self->{bz_in_process} + and $name =~ /\./ + and !grep( $_ eq $name, @$pre_process ) + and !Bugzilla::Hook::in('template_before_process') ) { - Bugzilla::Hook::process("template_before_process", - { vars => $stash, context => $self, - file => $name }); + state $WANT = Bugzilla::Hook::collect_wants('template_before_process_wants'); + if ( $WANT->{$name} ) { + my @extensions = grep { $WANT->{$name}{ blessed $_ } } @{ Bugzilla->extensions }; + Bugzilla::Hook::process( + "template_before_process" => { + vars => $stash, + context => $self, + file => $name + }, + \@extensions + ) if @extensions; + } } # This prevents other calls to stash() that might somehow happen |