I have added a custom hook to Bugzilla/Install/Util.pm
:
# Used by template_include_path.
sub _template_base_directories {
# ...
Bugzilla::Hook::process('template_dirs_alter', { template_dirs => \@template_dirs });
# ...
return \@template_dirs;
}
When executed via cgi, everything works fine, but using mod_perl
I can see using warn()
statements that the process statement above is executed for the custom hook, but the actual hook implementation is never invoked.
In Bugzilla/Hook.pm
:
sub process {
my ($name, $args) = @_;
# ...
foreach my $extension (@{ Bugzilla->extensions }) {
if ($extension->can($name)) {
# log shows the expected hook name and extension
# so the hook implementation is found
$extension->$name($args); # should invoke hook implementation, but doesn't
}
}
# ...
}
The hook is implemented in an Extension.pm like so:
sub template_dirs_alter {
my ($self, $args) = @_;
my ($template_dirs) = @$args{qw(template_dirs)};
if($something) {
push(@$template_dirs, "some/dir/path");
}
}
Any obvious gotchas with mod_perl and/or the Bugzilla hook/extension system I am missing here?
While the cwd
is usually the Bugzilla root when using cgi
, it can be anything when using mod_perl
(e.g. the apache home).
When using file paths in Bugzilla extensions, always prefix relative paths:
use File::Basename qw(dirname);
our $BASEDIR = dirname(__FILE__);
sub template_dirs_alter {
my ($self, $args) = @_;
my ($template_dirs) = @$args{qw(template_dirs)};
if($something) {
push(@$template_dirs, $BASEDIR . "some/dir/path");
}
}