From 2474b97150add16474f3071faeffc8faa4bff953 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Mon, 21 May 2018 22:18:27 -0400 Subject: support HTTPD_IN_SUBDIR for tests --- Bugzilla/Quantum.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Bugzilla/Quantum.pm') diff --git a/Bugzilla/Quantum.pm b/Bugzilla/Quantum.pm index 299b4bf42..7d679e3c3 100644 --- a/Bugzilla/Quantum.pm +++ b/Bugzilla/Quantum.pm @@ -22,6 +22,7 @@ use Bugzilla::Extension (); use Bugzilla::Install::Requirements (); use Bugzilla::Util (); use Bugzilla::RNG (); +use JSON::MaybeXS qw(decode_json); use Cwd qw(realpath); use MojoX::Log::Log4perl::Tiny; @@ -30,6 +31,30 @@ has 'static' => sub { Bugzilla::Quantum::Static->new }; sub startup { my ($self) = @_; + my %D; + if ($ENV{BUGZILLA_HTTPD_ARGS}) { + my $args = decode_json($ENV{BUGZILLA_HTTPD_ARGS}); + foreach my $arg (@$args) { + if ($arg =~ /^-D(\w+)$/) { + $D{$1} = 1; + } + else { + die "Unknown httpd arg: $arg"; + } + } + } + + $self->hook( + before_dispatch => sub { + my $c = shift; + + if ($D{HTTPD_IN_SUBDIR}) { + my $path = $c->req->url->path; + $path =~ s{^/bmo}{}s; + $c->req->url->path($path); + } + } + ); my $extensions = Bugzilla::Extension->load_all(); Bugzilla->preload_features(); -- cgit v1.2.3-24-g4f1b