]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Revert "Bug 1314201 - ThrowUserError and ThrowCodeError should print headers if heade...
authorDylan William Hardison <dylan@hardison.net>
Tue, 15 Nov 2016 14:28:58 +0000 (09:28 -0500)
committerDylan William Hardison <dylan@hardison.net>
Tue, 15 Nov 2016 14:28:58 +0000 (09:28 -0500)
This reverts commit 874e96c2423c772564c9dc63254baa99e86f270b.

Bugzilla/CGI.pm
Bugzilla/Error.pm
Bugzilla/Template.pm
template/en/default/global/code-error.html.tmpl

index ec8b8e52b17ff7c6836a7bb8e62a37d30d9cde63..78987ab711a6a43396312356041f84e2813ce05d 100644 (file)
@@ -21,7 +21,6 @@ use Bugzilla::Search::Recent;
 
 use File::Basename;
 use URI;
-use Carp qw(cluck);
 
 BEGIN {
     if (ON_WINDOWS) {
@@ -307,6 +306,7 @@ sub check_etag {
     return 0;
 }
 
+# Overwrite to ensure nph doesn't get set, and unset HEADERS_ONCE
 sub multipart_init {
     my $self = shift;
 
@@ -330,7 +330,6 @@ sub multipart_init {
     # CGI.pm's header() sets nph according to a param or $CGI::NPH, which
     # is the desired behaviour.
 
-    $self->{_bz_multipart} = 1;
     return $self->header(
         %param,
     ) . "WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY." . $self->multipart_end;
@@ -385,12 +384,7 @@ sub header {
     my %headers;
     my $user = Bugzilla->user;
 
-    if ($self->{_bz_headers_sent} && !$self->{_bz_multipart}) {
-        # cluck for the warning log so we can see where this was called.
-        cluck "attempt to send headers after headers already sent!";
-        ThrowCodeError("headers_already_sent");
-    }
-
+    # If there's only one parameter, then it's a Content-Type.
     if (scalar(@_) == 1) {
         %headers = ('-type' => shift(@_));
     }
@@ -466,18 +460,9 @@ sub header {
     Bugzilla::Hook::process('cgi_headers',
         { cgi => $self, headers => \%headers }
     );
+    $self->{_header_done} = 1;
 
-    my $headers = $self->SUPER::header(%headers) || "";
-    if ($headers && Bugzilla->usage_mode != USAGE_MODE_XMLRPC) {
-        $self->{_bz_headers_sent} = 1;
-    }
-
-    return $headers;
-}
-
-sub sent_headers {
-    my ($self) = @_;
-    return $self->{_bz_headers_sent};
+    return $self->SUPER::header(%headers) || "";
 }
 
 sub param {
index 226078f9cb450784576099d5c966afa78289f2f0..fc0e4812e8aa89611db216676884e84bc98fbf97 100644 (file)
@@ -112,7 +112,7 @@ sub _throw_error {
         }
 
         my $cgi = Bugzilla->cgi;
-        $cgi->close_standby_message('text/html', 'inline', 'error', 'html') unless $cgi->sent_headers;
+        $cgi->close_standby_message('text/html', 'inline', 'error', 'html');
         $template->process($name, $vars)
           || ThrowTemplateError($template->error());
         print $cgi->multipart_final() if $cgi->{_multipart_in_progress};
@@ -279,7 +279,7 @@ sub ThrowErrorPage {
         my $template = Bugzilla->template;
         my $vars = {};
         $vars->{message} = $message;
-        print $cgi->header() unless $cgi->sent_headers();
+        print $cgi->header();
         $template->process($template_name, $vars)
           || ThrowTemplateError($template->error());
         exit;
index dec9885c2618ec7eafaa17de5aa8597508cc778f..eb1496fca8f56c85f982555a0b425a74fa4fbf48 100644 (file)
@@ -653,21 +653,10 @@ our $is_processing = 0;
 
 sub process {
     my $self = shift;
-    my ($template, undef, $output) = @_;
-
-    if (!$output && Bugzilla->usage_mode == USAGE_MODE_BROWSER) {
-        # if $output is not passed, this will print.
-        my $cgi = Bugzilla->cgi;
-        unless ($cgi->sent_headers) {
-            warn "attempted to process $template before sending headers!";
-            print $cgi->header();
-        }
-    }
-
     # All of this current_langs stuff allows template_inner to correctly
     # determine what-language Template object it should instantiate.
     my $current_langs = Bugzilla->request_cache->{template_current_lang} ||= [];
-    unshift @$current_langs, $self->context->{bz_language};
+    unshift(@$current_langs, $self->context->{bz_language});
     local $is_processing = 1;
     my $retval = $self->SUPER::process(@_);
     shift @$current_langs;
index f78c954d716863dc8c0be2808ef147bb9276b6f0..18650de7d486c47fbf30389c7094a853c836abaa 100644 (file)
     [% title = "Field Type Not Specified" %]
     You must specify a type when creating a custom field.
 
-  [% ELSIF error == "headers_already_sent" %]
-    [% title = "Tried to send headers twice" %]
-    Somewhere inside [% terms.Bugzilla %], code attempted to sent HTTP headers more than once.
-
   [% ELSIF error == "illegal_content_type_method" %]
     Your form submission got corrupted somehow.  The <em>content
     method</em> field, which specifies how the content type gets determined,