summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-06-20 03:28:50 +0200
committerDylan William Hardison <dylan@hardison.net>2018-06-28 22:41:58 +0200
commite1b48df3b5cdd81920782a8585864af3b294e919 (patch)
tree13bb7c184950b6f1d911e387bbff817e42d1ee2d /Bugzilla
parent561a205df8fdb1950df167c6915d52601630c08a (diff)
downloadbugzilla-e1b48df3b5cdd81920782a8585864af3b294e919.tar.gz
bugzilla-e1b48df3b5cdd81920782a8585864af3b294e919.tar.xz
lots of hacking
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/DaemonControl.pm2
-rw-r--r--Bugzilla/Install/Filesystem.pm2
-rw-r--r--Bugzilla/Quantum.pm43
-rw-r--r--Bugzilla/Quantum/Plugin/Glue.pm44
-rw-r--r--Bugzilla/Template.pm4
5 files changed, 52 insertions, 43 deletions
diff --git a/Bugzilla/DaemonControl.pm b/Bugzilla/DaemonControl.pm
index aae06f9f7..19bc440f7 100644
--- a/Bugzilla/DaemonControl.pm
+++ b/Bugzilla/DaemonControl.pm
@@ -105,7 +105,7 @@ sub run_httpd {
# or else apache will kill its parent.
setsid();
$ENV{BUGZILLA_HTTPD_ARGS} = encode_json(\@args);
- my @command = ( $^X, '/app/scripts/bugzilla_quantum', 'daemon', "--listen=http://*:$ENV{PORT}" );
+ my @command = ( $^X, '/app/bugzilla.pl', 'daemon', "--listen=http://*:$ENV{PORT}" );
exec @command
or die "failed to exec $command[0] $!";
},
diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm
index b5d8bae08..583ce3f9b 100644
--- a/Bugzilla/Install/Filesystem.pm
+++ b/Bugzilla/Install/Filesystem.pm
@@ -231,6 +231,7 @@ sub FILESYSTEM {
'jobqueue-worker.pl' => { perms => OWNER_EXECUTE },
'clean-bug-user-last-visit.pl' => { perms => WS_EXECUTE },
+ 'bugzilla.pl' => { perms => OWNER_EXECUTE },
'Bugzilla.pm' => { perms => CGI_READ },
"$localconfig*" => { perms => CGI_READ },
'META.*' => { perms => CGI_READ },
@@ -240,7 +241,6 @@ sub FILESYSTEM {
'.htaccess' => { perms => WS_SERVE },
'cvs-update.log' => { perms => WS_SERVE },
'scripts/sendunsentbugmail.pl' => { perms => WS_EXECUTE },
- 'scripts/bugzilla_quantum' => { perms => CGI_READ },
'docs/bugzilla.ent' => { perms => OWNER_WRITE },
'docs/makedocs.pl' => { perms => OWNER_EXECUTE },
'docs/style.css' => { perms => WS_SERVE },
diff --git a/Bugzilla/Quantum.pm b/Bugzilla/Quantum.pm
index 5cc8c8243..7209a204b 100644
--- a/Bugzilla/Quantum.pm
+++ b/Bugzilla/Quantum.pm
@@ -31,42 +31,11 @@ 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();
- Bugzilla->template;
- $self->secrets([Bugzilla->localconfig->{side_wide_secret}]);
$self->plugin('Bugzilla::Quantum::Plugin::Glue');
- $self->log(
- MojoX::Log::Log4perl::Tiny->new(
- logger => Log::Log4perl->get_logger(__PACKAGE__)
- )
- );
+ my $port = $ENV{PORT} // 3000;
+ untaint($port);
+ $self->config(hypnotoad => {listen => ["http://*:$port"]});
my $r = $self->routes;
Bugzilla::Quantum::CGI->load_all($r);
@@ -74,6 +43,7 @@ sub startup {
$r->any('/')->to('CGI#index_cgi');
$r->any('/rest')->to('CGI#rest_cgi');
+ $r->any('/rest.cgi/*PATH_INFP')->to('CGI#rest_cgi' => { PATH_INFO => '' });
$r->any('/rest/*PATH_INFO')->to( 'CGI#rest_cgi' => { PATH_INFO => '' });
$r->any('/bug/:id')->to('CGI#show_bug_cgi');
$r->any('/extensions/BzAPI/bin/rest.cgi/*PATH_INFO')->to('CGI#bzapi_cgi');
@@ -83,9 +53,8 @@ sub startup {
$c->reply->file($c->app->home->child('__lbheartbeat__'));
},
);
-
- $r->any('/__heartbeat__')->to( 'CGI#heartbeat_cgi');
- $r->any('/robots.txt')->to( 'CGI#robots_cgi' );
+ $r->get('/__heartbeat__')->to( 'CGI#heartbeat_cgi');
+ $r->get('/robots.txt')->to( 'CGI#robots_cgi' );
$r->any('/review')->to( 'CGI#page_cgi' => {'id' => 'splinter.html'});
$r->any('/user_profile')->to( 'CGI#page_cgi' => {'id' => 'user_profile.html'});
diff --git a/Bugzilla/Quantum/Plugin/Glue.pm b/Bugzilla/Quantum/Plugin/Glue.pm
index 822987ad8..b46ffb1e1 100644
--- a/Bugzilla/Quantum/Plugin/Glue.pm
+++ b/Bugzilla/Quantum/Plugin/Glue.pm
@@ -11,12 +11,45 @@ use Mojo::Base 'Mojolicious::Plugin';
use Try::Tiny;
use Bugzilla::Constants;
use Bugzilla::Quantum::Template;
+use Bugzilla::Logging;
sub register {
my ( $self, $app, $conf ) = @_;
- my $template = Bugzilla::Template->create;
- $template->{_is_main} = 1;
+ 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";
+ }
+ }
+ }
+
+ $app->hook(
+ around_dispatch => sub {
+ my ($next, $c) = @_;
+
+ if ($D{HTTPD_IN_SUBDIR}) {
+ my $path = $c->req->url->path;
+ $path =~ s{^/bmo}{}s;
+ $c->req->url->path($path);
+ }
+ $next->();
+ }
+ );
+
+ Bugzilla::Extension->load_all();
+ if ($app->mode ne 'development') {
+ Bugzilla->preload_features();
+ DEBUG("preloading templates");
+ Bugzilla->preload_templates();
+ DEBUG("done preloading templates");
+ }
+ $app->secrets([Bugzilla->localconfig->{side_wide_secret}]);
$app->renderer->add_handler(
'bugzilla' => sub {
@@ -37,10 +70,17 @@ sub register {
unless ($name =~ /\./) {
$name = sprintf '%s.%s.tmpl', $options->{template}, $options->{format};
}
+ my $template = Bugzilla->template;
$template->process( $name, $vars, $output )
or die $template->error;
}
);
+
+ $app->log(
+ MojoX::Log::Log4perl::Tiny->new(
+ logger => Log::Log4perl->get_logger(ref $app)
+ )
+ );
}
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 9eea0d3dd..db2499ec5 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -571,7 +571,7 @@ sub create {
# if a packager has modified bz_locations() to contain absolute
# paths.
ABSOLUTE => 1,
- RELATIVE => $ENV{MOD_PERL} ? 0 : 1,
+ RELATIVE => $ENV{SERVER_SOFTWARE} ? 0 : 1,
# Only use an on-disk template cache if we're running as the web
# server. This ensures the permissions of the cache remain correct.
@@ -1040,7 +1040,7 @@ sub create {
# under mod_perl, use a provider (template loader) that preloads all templates into memory
my $provider_class
- = $ENV{MOD_PERL}
+ = $opts{preload}
? 'Bugzilla::Template::PreloadProvider'
: 'Template::Provider';