我已为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;
}
当通过cgi执行时,一切正常,但使用mod_perl
我可以看到使用warn()
语句,上面的流程语句是为自定义钩子执行的,但实际的钩子实现从不被调用。
在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
}
}
# ...
}
钩子在Extension.pm中实现,如下所示:
sub template_dirs_alter {
my ($self, $args) = @_;
my ($template_dirs) = @$args{qw(template_dirs)};
if($something) {
push(@$template_dirs, "some/dir/path");
}
}
我在这里找不到mod_perl和/或Bugzilla钩子/扩展系统的任何明显问题?
答案 0 :(得分:1)
我猜测_template_base_directories()
extensions
在loaded
下mod_perl
之前被调用DATE = MAX(DATE)
。如果是这种情况,那就是一个错误,应该修复。
答案 1 :(得分:0)
虽然使用cwd
时cgi
通常是Bugzilla根,但在使用mod_perl
时(例如apache home),它可以是任何内容。
在Bugzilla扩展程序中使用文件路径时,始终前缀相对路径:
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");
}
}