From 271477d8c26794abd8310e2abb89b746204660af Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Thu, 22 Apr 2010 11:02:17 -0700 Subject: Bug 560009: Use firstidx from List::MoreUtils instead of lsearch r=timello, a=mkanat --- Bugzilla.pm | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'Bugzilla.pm') diff --git a/Bugzilla.pm b/Bugzilla.pm index 8bcef7b28..2f21c6a18 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -62,17 +62,17 @@ use Safe; ##################################################################### # Scripts that are not stopped by shutdownhtml being in effect. -use constant SHUTDOWNHTML_EXEMPT => [ - 'editparams.cgi', - 'checksetup.pl', - 'migrate.pl', - 'recode.pl', -]; +use constant SHUTDOWNHTML_EXEMPT => qw( + editparams.cgi + checksetup.pl + migrate.pl + recode.pl +); # Non-cgi scripts that should silently exit. -use constant SHUTDOWNHTML_EXIT_SILENTLY => [ - 'whine.pl' -]; +use constant SHUTDOWNHTML_EXIT_SILENTLY => qw( + whine.pl +); ##################################################################### # Global Code @@ -112,8 +112,10 @@ sub init_page { }; } + my $script = basename($0); + # Because of attachment_base, attachment.cgi handles this itself. - if (basename($0) ne 'attachment.cgi') { + if ($script ne 'attachment.cgi') { do_ssl_redirect_if_required(); } @@ -123,14 +125,14 @@ sub init_page { # # This code must go here. It cannot go anywhere in Bugzilla::CGI, because # it uses Template, and that causes various dependency loops. - if (Bugzilla->params->{"shutdownhtml"} - && lsearch(SHUTDOWNHTML_EXEMPT, basename($0)) == -1) + if (Bugzilla->params->{"shutdownhtml"} + && !grep { $_ eq $script } SHUTDOWNHTML_EXEMPT) { # Allow non-cgi scripts to exit silently (without displaying any # message), if desired. At this point, no DBI call has been made # yet, and no error will be returned if the DB is inaccessible. - if (lsearch(SHUTDOWNHTML_EXIT_SILENTLY, basename($0)) > -1 - && !i_am_cgi()) + if (!i_am_cgi() + && grep { $_ eq $script } SHUTDOWNHTML_EXIT_SILENTLY) { exit; } -- cgit v1.2.3-65-gdbad