From 874e96c2423c772564c9dc63254baa99e86f270b Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Sat, 12 Nov 2016 11:41:08 -0500 Subject: Bug 1314201 - ThrowUserError and ThrowCodeError should print headers if headers have not already been printed --- Bugzilla/Template.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Bugzilla/Template.pm') diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index eb1496fca..dec9885c2 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -653,10 +653,21 @@ 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; -- cgit v1.2.3-24-g4f1b