使用mod_perl

时间:2016-03-01 18:35:11

标签: perl bugzilla mod-perl

我已为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钩子/扩展系统的任何明显问题?

2 个答案:

答案 0 :(得分:1)

我猜测_template_base_directories() extensionsloadedmod_perl之前被调用DATE = MAX(DATE)。如果是这种情况,那就是一个错误,应该修复。

答案 1 :(得分:0)

虽然使用cwdcgi通常是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");
    }
}