From bcfde177dbb9f3748f59af067357e5902335ca46 Mon Sep 17 00:00:00 2001 From: "mkanat%kerio.com" <> Date: Thu, 14 Jul 2005 13:01:34 +0000 Subject: Bug 283989: CGI.pl global init code should be moved to Bugzilla::CGI Patch By Max Kanat-Alexander r=wurblzap, a=justdave --- Bugzilla.pm | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'Bugzilla.pm') diff --git a/Bugzilla.pm b/Bugzilla.pm index 0deb6e16e..d3b1a5970 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -33,6 +33,59 @@ use Bugzilla::Constants; use Bugzilla::DB; use Bugzilla::Template; use Bugzilla::User; +use Bugzilla::Error; +use Bugzilla::Util; + +use File::Basename; + +##################################################################### +# Constants +##################################################################### + +# Scripts that are not stopped by shutdownhtml being in effect. +use constant SHUTDOWNHTML_EXEMPT => [ + 'doeditparams.cgi', + 'editparams.cgi', + 'checksetup.pl', +]; + +##################################################################### +# Global Code +##################################################################### + +# If Bugzilla is shut down, do not allow anything to run, just display a +# message to the user about the downtime. Scripts listed in +# SHUTDOWNHTML_EXEMPT are exempt from this message. +# +# This code must go here. It cannot go anywhere in Bugzilla::CGI, because +# it uses Template, and that causes various dependency loops. +if (Param("shutdownhtml") + && lsearch(SHUTDOWNHTML_EXEMPT, basename($0)) == -1) +{ + my $template = Bugzilla->template; + my $vars = {}; + $vars->{'message'} = 'shutdown'; + # Generate and return a message about the downtime, appropriately + # for if we're a command-line script or a CGI sript. + my $extension; + if (i_am_cgi() && (!Bugzilla->cgi->param('format') + || Bugzilla->cgi->param('format') eq 'html')) { + $extension = 'html'; + } + else { + $extension = 'txt'; + } + print Bugzilla->cgi->header() if i_am_cgi(); + my $t_output; + $template->process("global/message.$extension.tmpl", $vars, \$t_output) + || ThrowTemplateError($template->error); + print $t_output . "\n"; + exit; +} + +##################################################################### +# Subroutines and Methods +##################################################################### my $_template; sub template { -- cgit v1.2.3-24-g4f1b