summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-04-11 03:53:51 +0200
committerDylan William Hardison <dylan@hardison.net>2017-04-11 03:53:51 +0200
commit147f2fc9d9341e99dc17c3a267b80b7fc22a9699 (patch)
treedaf80083bb7ed8ebbbd9c168bb6bc78458d34777 /Bugzilla
parent15d83f334360acd3afec427cc5f08d4fd895a325 (diff)
downloadbugzilla-147f2fc9d9341e99dc17c3a267b80b7fc22a9699.tar.gz
bugzilla-147f2fc9d9341e99dc17c3a267b80b7fc22a9699.tar.xz
Revert "Bug 1352913 - Extensions must register for template_before_process()"
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Hook.pm44
-rw-r--r--Bugzilla/Template/Context.pm23
2 files changed, 21 insertions, 46 deletions
diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm
index e28c01a40..00bd316ab 100644
--- a/Bugzilla/Hook.pm
+++ b/Bugzilla/Hook.pm
@@ -11,42 +11,18 @@ use 5.10.1;
use strict;
use warnings;
-use Scalar::Util qw(blessed);
-
sub process {
- my ($name, $args, $extensions) = @_;
-
- $extensions //= Bugzilla->extensions;
-
- my $hook_stack = Bugzilla->request_cache->{hook_stack} ||= [];
- push @$hook_stack, $name;
-
- foreach my $extension (@$extensions) {
- if (my $hook = $extension->can($name)) {
- $hook->($extension, $args);
- }
- }
+ my ($name, $args) = @_;
- pop @$hook_stack;
-}
-
-sub collect_wants {
- my ($name) = @_;
- my %result;
+ _entering($name);
foreach my $extension (@{ Bugzilla->extensions }) {
- my $hook = $extension->can($name);
- if ($hook) {
- my $wants = $hook->($extension);
- foreach my $want (keys %$wants) {
- if ($wants->{$want}) {
- $result{ $want }{ blessed $extension } = 1;
- }
- }
+ if ($extension->can($name)) {
+ $extension->$name($args);
}
}
- return \%result;
+ _leaving($name);
}
sub in {
@@ -55,6 +31,16 @@ sub in {
return $hook_name eq $currently_in ? 1 : 0;
}
+sub _entering {
+ my ($hook_name) = @_;
+ my $hook_stack = Bugzilla->request_cache->{hook_stack} ||= [];
+ push(@$hook_stack, $hook_name);
+}
+
+sub _leaving {
+ pop @{ Bugzilla->request_cache->{hook_stack} };
+}
+
1;
__END__
diff --git a/Bugzilla/Template/Context.pm b/Bugzilla/Template/Context.pm
index e78cd9806..b81e32130 100644
--- a/Bugzilla/Template/Context.pm
+++ b/Bugzilla/Template/Context.pm
@@ -69,24 +69,13 @@ 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'))
{
- 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;
- }
+ Bugzilla::Hook::process("template_before_process",
+ { vars => $stash, context => $self,
+ file => $name });
}
# This prevents other calls to stash() that might somehow happen