summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-05-19 17:33:46 +0200
committerDylan William Hardison <dylan@hardison.net>2018-06-28 22:41:56 +0200
commit216af94b979206ee77d3f3b783648a959b120547 (patch)
tree8d08425a6b009558c4c1803f8dfba0de0d667fba
parent20c6de522aa4d27ba3c3f76d68c0b89424789270 (diff)
downloadbugzilla-216af94b979206ee77d3f3b783648a959b120547.tar.gz
bugzilla-216af94b979206ee77d3f3b783648a959b120547.tar.xz
more things
-rw-r--r--Bugzilla.pm3
-rw-r--r--Bugzilla/CGI.pm12
-rw-r--r--Bugzilla/CGI/Role.pm13
-rw-r--r--Bugzilla/Constants.pm2
-rw-r--r--Bugzilla/Quantum/CGI.pm62
-rw-r--r--Bugzilla/Quantum/Plugin/Glue.pm3
-rw-r--r--Bugzilla/Util.pm5
-rw-r--r--template/en/default/global/header.html.tmpl5
8 files changed, 72 insertions, 33 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index d5e49bb8d..ff588028c 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -576,9 +576,6 @@ sub usage_mode {
elsif ($newval == USAGE_MODE_REST) {
$class->error_mode(ERROR_MODE_REST);
}
- elsif ($newval == USAGE_MODE_QUANTUM) {
- $class->error_mode(ERROR_MODE_DIE);
- }
else {
ThrowCodeError('usage_mode_invalid',
{'invalid_usage_mode', $newval});
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';
diff --git a/template/en/default/global/header.html.tmpl b/template/en/default/global/header.html.tmpl
index 3d86dcf24..17cac3cb8 100644
--- a/template/en/default/global/header.html.tmpl
+++ b/template/en/default/global/header.html.tmpl
@@ -98,9 +98,7 @@
<meta charset="UTF-8">
[% END %]
[% USE Bugzilla %]
- [% IF Bugzilla.usage_mode == constants.USAGE_MODE_QUANTUM %]
- <base href="[% urlbase FILTER html %]">
- [% END %]
+ <base href="[% urlbase FILTER html %]">
[% IF Bugzilla.cgi.should_block_referrer %]
<meta name="referrer" content="origin">
@@ -109,7 +107,6 @@
[% END %]
[%- js_BUGZILLA = {
- QUANTUM => Bugzilla.usage_mode == constants.USAGE_MODE_QUANTUM,
param => {
maxattachmentsize => Param('maxattachmentsize'),
maxusermatches => Param('maxusermatches'),