summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla.pm14
-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
-rwxr-xr-xbugzilla.pl (renamed from scripts/bugzilla_quantum)2
-rw-r--r--vagrant_support/apache.yml6
8 files changed, 68 insertions, 49 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index 858fa6f44..4fbcd533e 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -193,8 +193,17 @@ sub init_page {
# Subroutines and Methods
#####################################################################
+my $preload_templates = 0;
+sub preload_templates {
+ $preload_templates = 1;
+
+ delete request_cache->{template};
+ template();
+ return 1;
+}
+
sub template {
- request_cache->{template} //= Bugzilla::Template->create();
+ request_cache->{template} //= Bugzilla::Template->create(preload => $preload_templates);
request_cache->{template}->{_is_main} = 1;
return request_cache->{template};
@@ -205,7 +214,8 @@ sub template_inner {
my $cache = request_cache;
my $current_lang = $cache->{template_current_lang}->[0];
$lang ||= $current_lang || '';
- return $cache->{"template_inner_$lang"} ||= Bugzilla::Template->create(language => $lang);
+ my %options = (language => $lang, preload => $preload_templates);
+ return $cache->{"template_inner_$lang"} ||= Bugzilla::Template->create(%options);
}
sub extensions {
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';
diff --git a/scripts/bugzilla_quantum b/bugzilla.pl
index 9069a2f05..505b44982 100755
--- a/scripts/bugzilla_quantum
+++ b/bugzilla.pl
@@ -9,7 +9,7 @@ use Cwd qw(realpath);
BEGIN {
require lib;
- my $dir = realpath( catdir(dirname(__FILE__), '..') );
+ my $dir = realpath( dirname(__FILE__) );
lib->import( $dir, catdir( $dir, 'lib' ), catdir( $dir, qw(local lib perl5) ) );
}
use Mojolicious::Commands;
diff --git a/vagrant_support/apache.yml b/vagrant_support/apache.yml
index 5031187e3..4ddd1e7b2 100644
--- a/vagrant_support/apache.yml
+++ b/vagrant_support/apache.yml
@@ -6,7 +6,7 @@
mode: 0644
when: LAZY == 0
-- name: enable httpd
+- name: disable httpd
service: name=httpd enabled=yes
when: LAZY == 0
@@ -16,5 +16,5 @@
- name: ensure bugzilla-json.log has right permissions
file: path=/vagrant/logs/bugzilla-json.log state=touch owner=vagrant group=apache mode=0660
-- name: restart httpd
- service: name=httpd state=restarted \ No newline at end of file
+- name: stop httpd
+ service: name=httpd state=stopped \ No newline at end of file