diff options
-rw-r--r-- | Bugzilla/CGI.pm | 9 | ||||
-rw-r--r-- | Bugzilla/Quantum.pm | 27 | ||||
-rw-r--r-- | Bugzilla/Quantum/CGI.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Quantum/Plugin/Glue.pm | 35 | ||||
-rw-r--r-- | Bugzilla/Quantum/Static.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Quantum/Template.pm | 3 | ||||
-rwxr-xr-x | editusers.cgi | 2 | ||||
-rwxr-xr-x | token.cgi | 3 | ||||
-rwxr-xr-x | userprefs.cgi | 2 |
9 files changed, 36 insertions, 49 deletions
diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index d43a26eab..2dedbc5f3 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -561,10 +561,9 @@ sub header { } } my $headers = $self->SUPER::header(%headers) || ''; - warn "if (". $self->server_software." eq 'Bugzilla::Quantum::Plugin::Glue') {"; if ($self->server_software eq 'Bugzilla::Quantum::Plugin::Glue') { my $c = Bugzilla->request_cache->{mojo_controller}; - $c->res->headers(Mojo::Headers->new->parse($headers)) if $headers; + $c->res->headers->parse($headers); return ''; } else { @@ -671,10 +670,12 @@ sub send_cookie { sub redirect { my $self = shift; $self->{bz_redirecting} = 1; - warn "redirect: @_\n"; + use Carp; + carp "redirect @_\n"; if ($self->server_software eq 'Bugzilla::Quantum::Plugin::Glue') { my $c = Bugzilla->request_cache->{mojo_controller}; - $c->redirect_to(@_); + $self->SUPER::redirect(@_); + $c->redirect_to($c->res->headers->location); return ''; } else { diff --git a/Bugzilla/Quantum.pm b/Bugzilla/Quantum.pm index 3f197a508..9b98bffa2 100644 --- a/Bugzilla/Quantum.pm +++ b/Bugzilla/Quantum.pm @@ -36,34 +36,13 @@ sub startup { my $rest = compile_cgi('rest.cgi'); $self->plugin('Bugzilla::Quantum::Plugin::Glue'); - $self->plugin( - 'MountPSGI' => { - rewrite => 1, - '/rest' => $rest, - } - ); - $self->plugin( - 'MountPSGI' => { - rewrite => 1, - '/rest.cgi' => $rest, - } - ); - $self->plugin( - 'MountPSGI' => { - rewrite => 1, - '/xmlrpc.cgi' => compile_cgi('xmlrpc.cgi'), - } - ); - $self->plugin( - 'MountPSGI' => { -rewrite => 1, - '/jsonrpc.cgi' => compile_cgi('jsonrpc.cgi'), - } - ); + my $r = $self->routes; Bugzilla::Quantum::CGI->expose_routes($r); $r->any('/')->to('CGI#handle_index'); + $r->any('/rest')->to('CGI#handle_rest'); + $r->any('/rest/*path_info')->to('CGI#handle_rest'); $r->get( '/__lbheartbeat__' => sub { 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; } diff --git a/editusers.cgi b/editusers.cgi index 9fbd550fe..d2ad3a82f 100755 --- a/editusers.cgi +++ b/editusers.cgi @@ -24,7 +24,7 @@ use Bugzilla::Field; use Bugzilla::Group; use Bugzilla::Token; -my $user = Bugzilla->login(LOGIN_REQUIRED); +local our $user = Bugzilla->login(LOGIN_REQUIRED); my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; @@ -217,7 +217,7 @@ sub changePassword { reason => 'Setting your password', password => $password, token => $token, - postback => { + postback => { action => 'token.cgi', token_field => 't', fields => { @@ -450,6 +450,7 @@ sub mfa_event_from_token { # create user from token my ($user_id) = Bugzilla::Token::GetTokenData($token); + warn "$user_id id from $token\n"; my $user = Bugzilla::User->check({ id => $user_id, cache => 1 }); # sanity check diff --git a/userprefs.cgi b/userprefs.cgi index e70b9780a..830c49eed 100755 --- a/userprefs.cgi +++ b/userprefs.cgi @@ -29,7 +29,7 @@ use DateTime; use constant SESSION_MAX => 20; -my $template = Bugzilla->template; +local our $template = Bugzilla->template; local our $vars = {}; ############################################################################### |