diff options
author | mkanat%bugzilla.org <> | 2009-12-17 05:27:10 +0000 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2009-12-17 05:27:10 +0000 |
commit | 9d6f961beaecf07741c2221146ed2c17e9c07594 (patch) | |
tree | bce3b8939f7092176f173e0da770e31c7784632c /Bugzilla/Template.pm | |
parent | 4f2eccc20de8b4ba8df9030ce07c836d2bae515b (diff) | |
download | bugs-9d6f961beaecf07741c2221146ed2c17e9c07594.tar bugs-9d6f961beaecf07741c2221146ed2c17e9c07594.tar.gz bugs-9d6f961beaecf07741c2221146ed2c17e9c07594.tar.bz2 bugs-9d6f961beaecf07741c2221146ed2c17e9c07594.tar.xz bugs-9d6f961beaecf07741c2221146ed2c17e9c07594.zip |
Bug 525606: Make the template_before_process hook run whenever a template is loaded (including PROCESS and INCLUDE), not just when $template->process is called.
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=dkl, a=mkanat
Diffstat (limited to 'Bugzilla/Template.pm')
-rw-r--r-- | Bugzilla/Template.pm | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index c8e3bc69c..046383094 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -80,25 +80,6 @@ sub _load_constants { return \%constants; } -# Overload Template::Process in order to add a hook to allow additional -# variables to be made available by an extension -sub process { - my $self = shift; - my ($file, $vars) = @_; - - # This hook can't call itself recursively, because otherwise we - # end up with problems when we throw an error inside of extensions - # (they end up in infinite recursion, because throwing an error involves - # processing a template). - if (!Bugzilla::Hook::in('template_before_process')) { - Bugzilla::Hook::process('template_before_process', - { vars => $vars, file => $file, - template => $self }); - } - - return $self->SUPER::process(@_); -} - # Returns the path to the templates based on the Accept-Language # settings of the user and of the available languages # If no Accept-Language is present it uses the defined default @@ -487,7 +468,7 @@ sub create { COMPILE_DIR => bz_locations()->{'datadir'} . "/template", # Initialize templates (f.e. by loading plugins like Hook). - PRE_PROCESS => "global/initialize.none.tmpl", + PRE_PROCESS => ["global/initialize.none.tmpl"], ENCODING => Bugzilla->params->{'utf8'} ? 'UTF-8' : undef, @@ -802,6 +783,8 @@ sub create { }, }; + local $Template::Config::CONTEXT = 'Bugzilla::Template::Context'; + Bugzilla::Hook::process('template_before_create', { config => $config }); my $template = $class->new($config) || die("Template creation failed: " . $class->error()); |