summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Quantum
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-05-21 17:38:41 +0200
committerDylan William Hardison <dylan@hardison.net>2018-06-28 22:41:56 +0200
commit3517d8a6687cd37cb8c9009a78f16071d652254a (patch)
tree135535be087ee773e710e0c6d762283a3dfbb902 /Bugzilla/Quantum
parent873074873fe5e27e853e5ce3d83b078280a29c2a (diff)
downloadbugzilla-3517d8a6687cd37cb8c9009a78f16071d652254a.tar.gz
bugzilla-3517d8a6687cd37cb8c9009a78f16071d652254a.tar.xz
almost working
Diffstat (limited to 'Bugzilla/Quantum')
-rw-r--r--Bugzilla/Quantum/CGI.pm2
-rw-r--r--Bugzilla/Quantum/Plugin/Glue.pm35
-rw-r--r--Bugzilla/Quantum/Static.pm2
-rw-r--r--Bugzilla/Quantum/Template.pm3
4 files changed, 24 insertions, 18 deletions
diff --git a/Bugzilla/Quantum/CGI.pm b/Bugzilla/Quantum/CGI.pm
index 4d43158cc..fab2b145d 100644
--- a/Bugzilla/Quantum/CGI.pm
+++ b/Bugzilla/Quantum/CGI.pm
@@ -16,7 +16,6 @@ use Sub::Quote 2.005000;
use Taint::Util qw(untaint);
my %CGIS;
-my %SKIP = ( 'xmlrpc.cgi' => 1, 'jsonrpc.cgi' => 1, 'rest.cgi' => 1);
_load_all();
@@ -29,7 +28,6 @@ sub expose_routes {
sub _load_all {
foreach my $script (glob '*.cgi') {
- next if $SKIP{$script};
my $name = _load_cgi($script);
$CGIS{ $script } = $name;
}
diff --git a/Bugzilla/Quantum/Plugin/Glue.pm b/Bugzilla/Quantum/Plugin/Glue.pm
index 2e3ecf4f0..17dc443c6 100644
--- a/Bugzilla/Quantum/Plugin/Glue.pm
+++ b/Bugzilla/Quantum/Plugin/Glue.pm
@@ -13,6 +13,7 @@ use Bugzilla::Constants;
use Bugzilla::Quantum::Template;
use Socket qw(AF_INET inet_aton);
use Sys::Hostname;
+use IO::String;
sub register {
my ( $self, $app, $conf ) = @_;
@@ -23,7 +24,7 @@ sub register {
$app->renderer->add_handler(
'bugzilla' => sub {
my ( $renderer, $c, $output, $options ) = @_;
- my %params;
+ my $vars = delete $c->stash->{vars};
# Helpers
my %helper;
@@ -31,16 +32,15 @@ sub register {
my $sub = $renderer->helpers->{$method};
$helper{$method} = sub { $c->$sub(@_) };
}
- $params{helper} = \%helper;
+ $vars->{helper} = \%helper;
- # Stash values
- $params{$_} = $c->stash->{$_} for grep {m/^\w+\z/} keys %{ $c->stash };
- $params{self} = $params{c} = $c;
+ # The controller
+ $vars->{c} = $c;
my $name = $options->{template};
unless ($name =~ /\./) {
$name = sprintf '%s.%s.tmpl', $options->{template}, $options->{format};
}
- $template->process( $name, \%params, $output )
+ $template->process( $name, $vars, $output )
or die $template->error;
}
);
@@ -48,21 +48,32 @@ sub register {
$app->hook(
around_dispatch => sub {
my ($next, $c) = @_;
+ local %ENV = _ENV($c);
+ my $stdin = _STDIN($c);
+ my $stdout = '';
try {
local $CGI::Compile::USE_REAL_EXIT = 0;
- local %ENV = _ENV($c);
- my $stdin = _STDIN($c);
- warn "stdin path ", $stdin->path, "\n";
- local *STDIN;
+ local *STDIN; ## no critic (local)
+ local *STDOUT;
open STDIN, '<', $stdin->path or die "STDIN @{[$stdin->path]}: $!" if -s $stdin->path;
+ open STDOUT, '>', \$stdout or die "STDOUT capture: $!";
+
Bugzilla::init_page();
Bugzilla->request_cache->{mojo_controller} = $c;
Bugzilla->template( Bugzilla::Quantum::Template->new( controller => $c, template => $template ) );
$next->();
+ }
+ catch {
+ die $_ unless ref $_ eq 'ARRAY' && $_->[0] eq "EXIT\n" || /\bModPerl::Util::exit\b/;
+ }
+ finally {
+ if (length $stdout) {
+ warn "setting body\n";
+ $c->res->body($stdout);
+ $c->rendered;
+ }
Bugzilla::_cleanup; ## no critic (private)
CGI::initialize_globals();
- } catch {
- die $_ unless ref $_ eq 'ARRAY' && $_->[0] eq "EXIT\n" || /\bModPerl::Util::exit\b/;
};
}
);
diff --git a/Bugzilla/Quantum/Static.pm b/Bugzilla/Quantum/Static.pm
index 2bd0555e2..2bb54990e 100644
--- a/Bugzilla/Quantum/Static.pm
+++ b/Bugzilla/Quantum/Static.pm
@@ -20,11 +20,9 @@ sub file {
if (my ($legacy_rel) = $rel =~ $LEGACY_RE) {
local $self->{paths} = [ bz_locations->{cgi_path} ];
- warn "legacy $legacy_rel\n";
return $self->SUPER::file($legacy_rel);
}
else {
- warn "mojo $rel\n";
return $self->SUPER::file($rel);
}
}
diff --git a/Bugzilla/Quantum/Template.pm b/Bugzilla/Quantum/Template.pm
index ebae0cf9f..2442f1134 100644
--- a/Bugzilla/Quantum/Template.pm
+++ b/Bugzilla/Quantum/Template.pm
@@ -24,8 +24,7 @@ sub process {
my ($self, $file, $vars, $output) = @_;
if (@_ < 4) {
- my $stash = $self->controller->stash;
- $stash->{$_} = $vars->{$_} for keys %$vars;
+ $self->controller->stash->{vars} = $vars;
$self->controller->render(template => $file, handler => 'bugzilla');
return 1;
}