diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/CGI.pm | 12 | ||||
-rw-r--r-- | Bugzilla/CGI/Role.pm | 13 | ||||
-rw-r--r-- | Bugzilla/Constants.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Quantum/CGI.pm | 62 | ||||
-rw-r--r-- | Bugzilla/Quantum/Plugin/Glue.pm | 3 | ||||
-rw-r--r-- | Bugzilla/Util.pm | 5 |
6 files changed, 71 insertions, 26 deletions
diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index 8158cb9c2..1a191daaa 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -658,18 +658,6 @@ sub send_cookie { push(@{$self->{'Bugzilla_cookie_list'}}, $self->cookie(%paramhash)); } -# Cookies are removed by setting an expiry date in the past. -# This method is a send_cookie wrapper doing exactly this. -sub remove_cookie { - my $self = shift; - my ($cookiename) = (@_); - - # Expire the cookie, giving a non-empty dummy value (bug 268146). - $self->send_cookie('-name' => $cookiename, - '-expires' => 'Tue, 15-Sep-1998 21:49:00 GMT', - '-value' => 'X'); -} - # To avoid infinite redirection recursion, track when we're within a redirect # request. sub redirect { diff --git a/Bugzilla/CGI/Role.pm b/Bugzilla/CGI/Role.pm index 1d674180e..33807eb7e 100644 --- a/Bugzilla/CGI/Role.pm +++ b/Bugzilla/CGI/Role.pm @@ -68,4 +68,17 @@ sub csp_nonce { return $csp->has_nonce ? $csp->nonce : ''; } +# Cookies are removed by setting an expiry date in the past. +# This method is a send_cookie wrapper doing exactly this. +sub remove_cookie { + my ($self, $name) = @_; + + # Expire the cookie, giving a non-empty dummy value (bug 268146). + $self->send_cookie( + '-name' => $name, + '-expires' => 'Tue, 15-Sep-1998 21:49:00 GMT', + '-value' => 'X' + ); +} + 1; diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index f679fe0d2..02e95cffc 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -131,7 +131,6 @@ use Memoize; USAGE_MODE_JSON USAGE_MODE_TEST USAGE_MODE_REST - USAGE_MODE_QUANTUM ERROR_MODE_WEBPAGE ERROR_MODE_DIE @@ -489,7 +488,6 @@ use constant USAGE_MODE_EMAIL => 3; use constant USAGE_MODE_JSON => 4; use constant USAGE_MODE_TEST => 5; use constant USAGE_MODE_REST => 6; -use constant USAGE_MODE_QUANTUM => 7; # Error modes. Default set by Bugzilla->usage_mode (so ERROR_MODE_WEBPAGE # usually). Use with Bugzilla->error_mode. diff --git a/Bugzilla/Quantum/CGI.pm b/Bugzilla/Quantum/CGI.pm index dd893a0f0..4cbbe0418 100644 --- a/Bugzilla/Quantum/CGI.pm +++ b/Bugzilla/Quantum/CGI.pm @@ -7,11 +7,12 @@ package Bugzilla::Quantum::CGI; use 5.10.1; +use Carp qw(confess); use Moo; has 'controller' => ( is => 'ro', - handles => [qw(param cookie)], + handles => [qw[req res]], ); has 'csp_object' => ( @@ -24,33 +25,76 @@ with 'Bugzilla::CGI::Role'; sub script_name { my ($self) = @_; - return $self->controller->req->env->{SCRIPT_NAME}; + return $self->req->env->{SCRIPT_NAME}; } sub referer { my ($self) = @_; - my $c = $self->controller; - return $c->req->headers->referrer; + return $self->req->headers->referrer; } sub http { my ($self, $header) = @_; - return $self->controller->req->headers->header($header); + return $self->req->headers->header($header); } sub header { my ($self, @args) = @_; - my $c = $self->controller; return '' if @args == 0; if (@args == 1) { - $c->res->headers->content_type($args[0]); + $self->res->headers->content_type($args[0]); } return ''; } +sub cookie { ## no critic (unpack) + my $self = shift; + my $c = $self->controller; + if (@_ == 1 && !ref $_[0]) { + my ($name) = @_; + return $c->cookie($name); + } + else { + die "cookie(@_) is not understood"; + } +} + +sub user_agent { + my $self = shift; + + return $self->req->headers->user_agent; +} + +sub url { ## no critic (unpack) + my $self = shift; + my $c = $self->controller; + if ($_[0] eq '-relative' && $_[1] == 1) { + return $c->url_for; + } + else { + confess "url(@_) is not understood"; + } +} + +sub param { ## no critic (unpack) + my $self = shift; + if (@_ == 1) { + my ($name) = @_; + return $self->req->param($name); + } + else { + die "param(@_) is not understood"; + } +} + +sub delete { ## no critic (builtin) + my ($self, $name) = @_; + $self->req->params->remove($name); +} + sub redirect { my ($self, $location) = @_; @@ -60,13 +104,13 @@ sub redirect { sub Vars { my ($self) = @_; - return $self->controller->req->query_params->to_hash; + return $self->req->query_params->to_hash; } sub query_string { my ($self) = @_; - return $self->controller->req->query_params->to_string; + return $self->req->query_params->to_string; } sub send_cookie { diff --git a/Bugzilla/Quantum/Plugin/Glue.pm b/Bugzilla/Quantum/Plugin/Glue.pm index 6c20d87f7..a28c2598d 100644 --- a/Bugzilla/Quantum/Plugin/Glue.pm +++ b/Bugzilla/Quantum/Plugin/Glue.pm @@ -48,7 +48,8 @@ sub register { try { local %{ Bugzilla->request_cache } = (); local $CGI::Compile::USE_REAL_EXIT = 0; - Bugzilla->usage_mode(USAGE_MODE_QUANTUM); + # HACK, should just make i_am_cgi smarter. + local $ENV{'SERVER_SOFTWARE'} = 1; Bugzilla->cgi( Bugzilla::Quantum::CGI->new(controller => $c) ); Bugzilla->template( Bugzilla::Quantum::Template->new( controller => $c, template => $template ) ); $next->(); diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 8e60944b0..ed1d4593c 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -321,8 +321,9 @@ sub do_ssl_redirect_if_required { # Returns the real remote address of the client, sub remote_ip { - if (Bugzilla->usage_mode == USAGE_MODE_QUANTUM) { - return Bugzilla->cgi->controller->tx->remote_address; + my $cgi = Bugzilla->cgi; + if ($cgi->can('controller')) { + return $cgi->controller->tx->remote_address; } else { my $remote_ip = $ENV{'REMOTE_ADDR'} || '127.0.0.1'; |