From 319f68a68e0196e9b54e091d39df4ec2d40b48e7 Mon Sep 17 00:00:00 2001 From: "kiko%async.com.br" Date: Sat, 27 Mar 2004 03:51:44 +0000 Subject: [PATCH] Fix for bug 234175: Remove deprecated ConnectToDatabase() and quietly_check_login()/confirm_login() calls. Cleans up callsites (consisting of most of our CGIs), swapping (where appropriate) for calls to Bugzilla->login. Patch by Teemu Mannermaa . r=bbaetz, kiko. a=justdave. git-svn-id: svn://10.0.0.236/trunk@154331 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bugzilla/DB.pm | 10 +--------- mozilla/webtools/bugzilla/CGI.pl | 8 -------- mozilla/webtools/bugzilla/attachment.cgi | 18 ++++++++---------- mozilla/webtools/bugzilla/buglist.cgi | 15 +++++++-------- mozilla/webtools/bugzilla/chart.cgi | 5 ++--- mozilla/webtools/bugzilla/colchange.cgi | 3 +-- mozilla/webtools/bugzilla/collectstats.pl | 1 - mozilla/webtools/bugzilla/config.cgi | 4 ---- mozilla/webtools/bugzilla/contrib/bug_email.pl | 4 +--- .../bugzilla/contrib/bugzilla_email_append.pl | 2 -- mozilla/webtools/bugzilla/contrib/syncLDAP.pl | 2 -- mozilla/webtools/bugzilla/createaccount.cgi | 4 +--- .../webtools/bugzilla/describecomponents.cgi | 7 +++---- mozilla/webtools/bugzilla/describekeywords.cgi | 4 +--- mozilla/webtools/bugzilla/doeditparams.cgi | 4 ++-- mozilla/webtools/bugzilla/duplicates.cgi | 3 +-- mozilla/webtools/bugzilla/editcomponents.cgi | 4 ++-- mozilla/webtools/bugzilla/editflagtypes.cgi | 6 ++---- mozilla/webtools/bugzilla/editgroups.cgi | 3 +-- mozilla/webtools/bugzilla/editkeywords.cgi | 4 ++-- mozilla/webtools/bugzilla/editmilestones.cgi | 4 ++-- mozilla/webtools/bugzilla/editparams.cgi | 4 ++-- mozilla/webtools/bugzilla/editproducts.cgi | 3 +-- mozilla/webtools/bugzilla/editusers.cgi | 4 ++-- mozilla/webtools/bugzilla/editversions.cgi | 4 ++-- mozilla/webtools/bugzilla/enter_bug.cgi | 11 +++-------- mozilla/webtools/bugzilla/importxml.pl | 1 - mozilla/webtools/bugzilla/index.cgi | 6 ++---- mozilla/webtools/bugzilla/long_list.cgi | 4 +--- mozilla/webtools/bugzilla/move.pl | 4 ++-- mozilla/webtools/bugzilla/page.cgi | 4 +--- mozilla/webtools/bugzilla/post_bug.cgi | 3 +-- mozilla/webtools/bugzilla/process_bug.cgi | 3 +-- mozilla/webtools/bugzilla/query.cgi | 8 ++++---- mozilla/webtools/bugzilla/queryhelp.cgi | 3 +-- mozilla/webtools/bugzilla/quips.cgi | 5 +++-- mozilla/webtools/bugzilla/relogin.cgi | 6 ++---- mozilla/webtools/bugzilla/report.cgi | 5 ++--- mozilla/webtools/bugzilla/reports.cgi | 3 +-- mozilla/webtools/bugzilla/request.cgi | 5 +---- mozilla/webtools/bugzilla/sanitycheck.cgi | 4 +--- mozilla/webtools/bugzilla/show_activity.cgi | 4 +--- mozilla/webtools/bugzilla/show_bug.cgi | 7 +++---- .../webtools/bugzilla/showdependencygraph.cgi | 4 +--- .../webtools/bugzilla/showdependencytree.cgi | 4 +--- mozilla/webtools/bugzilla/sidebar.cgi | 3 +-- mozilla/webtools/bugzilla/token.cgi | 6 +++--- mozilla/webtools/bugzilla/userprefs.cgi | 3 +-- mozilla/webtools/bugzilla/votes.cgi | 7 +++---- mozilla/webtools/bugzilla/whineatnews.pl | 2 -- 50 files changed, 84 insertions(+), 161 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla/DB.pm b/mozilla/webtools/bugzilla/Bugzilla/DB.pm index a747aebd6ce..684869006ec 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/DB.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/DB.pm @@ -33,7 +33,7 @@ use base qw(Exporter); %Bugzilla::DB::EXPORT_TAGS = ( - deprecated => [qw(ConnectToDatabase SendSQL SqlQuote + deprecated => [qw(SendSQL SqlQuote MoreSQLData FetchSQLData FetchOneColumn PushGlobalSQLState PopGlobalSQLState) ], @@ -49,10 +49,6 @@ use Bugzilla::Util; # having a separate package for it, or otherwise trying to avoid the circular # dependancy -sub ConnectToDatabase { - # We've already been connected in Bugzilla.pm -} - # XXX - mod_perl # These use |our| instead of |my| because they need to be cleared from # Bugzilla.pm. See bug 192531 for details. @@ -222,10 +218,6 @@ and so are not documented. =item * -ConnectToDatabase - -=item * - SendSQL =item * diff --git a/mozilla/webtools/bugzilla/CGI.pl b/mozilla/webtools/bugzilla/CGI.pl index 982b067b224..6d10268d387 100644 --- a/mozilla/webtools/bugzilla/CGI.pl +++ b/mozilla/webtools/bugzilla/CGI.pl @@ -198,10 +198,6 @@ sub PasswordForLogin { return $result; } -sub quietly_check_login { - return Bugzilla->login($_[0] ? LOGIN_OPTIONAL : LOGIN_NORMAL); -} - sub CheckEmailSyntax { my ($addr) = (@_); my $match = Param('emailregexp'); @@ -224,10 +220,6 @@ sub MailPassword { close SENDMAIL; } -sub confirm_login { - return Bugzilla->login(LOGIN_REQUIRED); -} - sub PutHeader { ($vars->{'title'}, $vars->{'h1'}, $vars->{'h2'}) = (@_); diff --git a/mozilla/webtools/bugzilla/attachment.cgi b/mozilla/webtools/bugzilla/attachment.cgi index 8df56212002..61565f01f6a 100755 --- a/mozilla/webtools/bugzilla/attachment.cgi +++ b/mozilla/webtools/bugzilla/attachment.cgi @@ -42,16 +42,14 @@ use vars qw( require "CGI.pl"; # Use these modules to handle flags. +use Bugzilla::Constants; use Bugzilla::Flag; use Bugzilla::FlagType; use Bugzilla::User; use Bugzilla::Util; -# Establish a connection to the database backend. -ConnectToDatabase(); - # Check whether or not the user is logged in and, if so, set the $::userid -quietly_check_login(); +Bugzilla->login(); # The ID of the bug to which the attachment is attached. Gets set # by validateID() (which validates the attachment ID, not the bug ID, but has @@ -104,14 +102,14 @@ elsif ($action eq "viewall") } elsif ($action eq "enter") { - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); ValidateBugID($::FORM{'bugid'}); validateCanChangeBug($::FORM{'bugid'}); enter(); } elsif ($action eq "insert") { - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); ValidateBugID($::FORM{'bugid'}); validateCanChangeBug($::FORM{'bugid'}); ValidateComment($::FORM{'comment'}); @@ -125,14 +123,13 @@ elsif ($action eq "insert") } elsif ($action eq "edit") { - quietly_check_login(); validateID(); validateCanEdit($::FORM{'id'}); edit(); } elsif ($action eq "update") { - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); ValidateComment($::FORM{'comment'}); validateID(); validateCanEdit($::FORM{'id'}); @@ -216,9 +213,10 @@ sub validateCanEdit my ($attach_id) = (@_); # If the user is not logged in, claim that they can edit. This allows - # the edit scrren to be displayed to people who aren't logged in. + # the edit screen to be displayed to people who aren't logged in. # People not logged in can't actually commit changes, because that code - # calls confirm_login, not quietly_check_login, before calling this sub + # calls Bugzilla->login with LOGIN_REQUIRED, not with LOGIN_NORMAL, + # before calling this sub return if $::userid == 0; # People in editbugs can edit all attachments diff --git a/mozilla/webtools/bugzilla/buglist.cgi b/mozilla/webtools/bugzilla/buglist.cgi index 8a02ca4906e..2a71450aaf2 100755 --- a/mozilla/webtools/bugzilla/buglist.cgi +++ b/mozilla/webtools/bugzilla/buglist.cgi @@ -37,6 +37,7 @@ use vars qw($template $vars); use Bugzilla; use Bugzilla::Search; +use Bugzilla::Constants; # Include the Bugzilla CGI and general utility library. require "CGI.pl"; @@ -63,8 +64,6 @@ if (length($::buffer) == 0) { ThrowUserError("buglist_parameters_required"); } -ConnectToDatabase(); - ################################################################################ # Data and Security Validation ################################################################################ @@ -74,12 +73,12 @@ my $dotweak = $::FORM{'tweak'} ? 1 : 0; # Log the user in if ($dotweak) { - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); UserInGroup("editbugs") || ThrowUserError("insufficient_privs_for_multi"); GetVersionTable(); } else { - quietly_check_login(); + Bugzilla->login(); } # Hack to support legacy applications that think the RDF ctype is at format=rdf. @@ -182,7 +181,7 @@ sub iCalendarDateTime { sub LookupNamedQuery { my ($name) = @_; - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"}); my $qname = SqlQuote($name); SendSQL("SELECT query FROM namedqueries WHERE userid = $userid AND name = $qname"); @@ -305,7 +304,7 @@ if ($::FORM{'cmdtype'} eq "dorem") { $order = $params->param('order') || $order; } elsif ($::FORM{'remaction'} eq "forget") { - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"}); my $qname = SqlQuote($::FORM{'namedcmd'}); SendSQL("DELETE FROM namedqueries WHERE userid = $userid AND name = $qname"); @@ -325,7 +324,7 @@ if ($::FORM{'cmdtype'} eq "dorem") { } elsif (($::FORM{'cmdtype'} eq "doit") && $::FORM{'remtype'}) { if ($::FORM{'remtype'} eq "asdefault") { - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"}); my $qname = SqlQuote($::defaultqueryname); my $qbuffer = SqlQuote($::buffer); @@ -335,7 +334,7 @@ elsif (($::FORM{'cmdtype'} eq "doit") && $::FORM{'remtype'}) { $vars->{'message'} = "buglist_new_default_query"; } elsif ($::FORM{'remtype'} eq "asnamed") { - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"}); my $name = trim($::FORM{'newqueryname'}); diff --git a/mozilla/webtools/bugzilla/chart.cgi b/mozilla/webtools/bugzilla/chart.cgi index dbdd818bc0e..229e9bbf7b6 100755 --- a/mozilla/webtools/bugzilla/chart.cgi +++ b/mozilla/webtools/bugzilla/chart.cgi @@ -45,6 +45,7 @@ use strict; use lib qw(.); require "CGI.pl"; +use Bugzilla::Constants; use Bugzilla::Chart; use Bugzilla::Series; @@ -81,9 +82,7 @@ if ($action eq "search") { exit; } -ConnectToDatabase(); - -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); # Only admins may create public queries UserInGroup('admin') || $cgi->delete('public'); diff --git a/mozilla/webtools/bugzilla/colchange.cgi b/mozilla/webtools/bugzilla/colchange.cgi index 726e60d510a..dcd611dad57 100755 --- a/mozilla/webtools/bugzilla/colchange.cgi +++ b/mozilla/webtools/bugzilla/colchange.cgi @@ -36,8 +36,7 @@ use Bugzilla; require "CGI.pl"; -ConnectToDatabase(); -quietly_check_login(); +Bugzilla->login(); GetVersionTable(); diff --git a/mozilla/webtools/bugzilla/collectstats.pl b/mozilla/webtools/bugzilla/collectstats.pl index e0416945314..7391d32da1c 100755 --- a/mozilla/webtools/bugzilla/collectstats.pl +++ b/mozilla/webtools/bugzilla/collectstats.pl @@ -51,7 +51,6 @@ if (chdir("graphs")) { chdir(".."); } -ConnectToDatabase(); GetVersionTable(); Bugzilla->switch_to_shadow_db(); diff --git a/mozilla/webtools/bugzilla/config.cgi b/mozilla/webtools/bugzilla/config.cgi index f7cb95ee52b..a2c22d0019b 100755 --- a/mozilla/webtools/bugzilla/config.cgi +++ b/mozilla/webtools/bugzilla/config.cgi @@ -33,10 +33,6 @@ use strict; use lib qw(.); require "CGI.pl"; -# Connect to the database so we can check whether the user is a member -# of each product group. -ConnectToDatabase(); - # Retrieve this installation's configuration. GetVersionTable(); diff --git a/mozilla/webtools/bugzilla/contrib/bug_email.pl b/mozilla/webtools/bugzilla/contrib/bug_email.pl index 8a5e1544b10..c697f5b9849 100755 --- a/mozilla/webtools/bugzilla/contrib/bug_email.pl +++ b/mozilla/webtools/bugzilla/contrib/bug_email.pl @@ -38,7 +38,7 @@ # # You need to work with bug_email.pl the MIME::Parser installed. # -# $Id: bug_email.pl,v 1.18 2004-01-20 06:03:38 justdave%syndicomm.com Exp $ +# $Id: bug_email.pl,v 1.19 2004-03-27 03:51:44 kiko%async.com.br Exp $ ############################################################### # 02/12/2000 (SML) @@ -746,8 +746,6 @@ die (" *** Cant find Sender-adress in sent mail ! ***\n" ) unless defined( $Send chomp( $Sender ); chomp( $Message_ID ); -ConnectToDatabase(); - $SenderShort = $Sender; $SenderShort =~ s/^.*?([a-zA-Z0-9_.-]+?\@[a-zA-Z0-9_.-]+\.[a-zA-Z0-9_.-]+).*$/$1/; diff --git a/mozilla/webtools/bugzilla/contrib/bugzilla_email_append.pl b/mozilla/webtools/bugzilla/contrib/bugzilla_email_append.pl index da098e66c5a..007fd153ce6 100755 --- a/mozilla/webtools/bugzilla/contrib/bugzilla_email_append.pl +++ b/mozilla/webtools/bugzilla/contrib/bugzilla_email_append.pl @@ -68,8 +68,6 @@ chomp( $Message_ID ); print "Dealing with the sender $Sender\n"; -ConnectToDatabase(); - my $SenderShort = $Sender; $SenderShort =~ s/^.*?([a-zA-Z0-9_.-]+?\@[a-zA-Z0-9_.-]+\.[a-zA-Z0-9_.-]+).*$/$1/; diff --git a/mozilla/webtools/bugzilla/contrib/syncLDAP.pl b/mozilla/webtools/bugzilla/contrib/syncLDAP.pl index 701695aea4b..b9d3e8a5fa2 100755 --- a/mozilla/webtools/bugzilla/contrib/syncLDAP.pl +++ b/mozilla/webtools/bugzilla/contrib/syncLDAP.pl @@ -74,8 +74,6 @@ foreach my $arg (@ARGV) } } -ConnectToDatabase(); - my %bugzilla_users; my %ldap_users; diff --git a/mozilla/webtools/bugzilla/createaccount.cgi b/mozilla/webtools/bugzilla/createaccount.cgi index 6c624b0ba4c..6364e20bcb1 100755 --- a/mozilla/webtools/bugzilla/createaccount.cgi +++ b/mozilla/webtools/bugzilla/createaccount.cgi @@ -36,13 +36,11 @@ use vars qw( $vars ); -ConnectToDatabase(); - # If we're using LDAP for login, then we can't create a new account here. unless (Bugzilla::Auth->can_edit) { # Just in case someone already has an account, let them get the correct # footer on the error message - quietly_check_login(); + Bugzilla->login(); ThrowUserError("auth_cant_create_account"); } diff --git a/mozilla/webtools/bugzilla/describecomponents.cgi b/mozilla/webtools/bugzilla/describecomponents.cgi index 1926a882699..6c99a0a6336 100755 --- a/mozilla/webtools/bugzilla/describecomponents.cgi +++ b/mozilla/webtools/bugzilla/describecomponents.cgi @@ -23,7 +23,6 @@ use vars qw( %legal_product - $userid ); use strict; @@ -31,11 +30,11 @@ use strict; use lib qw(.); use Bugzilla; +use Bugzilla::Constants; require "CGI.pl"; -ConnectToDatabase(); -quietly_check_login(); +Bugzilla->login(); GetVersionTable(); @@ -48,7 +47,7 @@ if (!defined $product) { if (AnyEntryGroups()) { # OK, now only add products the user can see - confirm_login() unless $::userid; + Bugzilla->login(LOGIN_REQUIRED) unless Bugzilla->user; foreach my $p (@::legal_product) { if (CanEnterProduct($p)) { $products{$p} = $::proddesc{$p}; diff --git a/mozilla/webtools/bugzilla/describekeywords.cgi b/mozilla/webtools/bugzilla/describekeywords.cgi index 60c5a9fd8eb..8597e67910d 100755 --- a/mozilla/webtools/bugzilla/describekeywords.cgi +++ b/mozilla/webtools/bugzilla/describekeywords.cgi @@ -31,9 +31,7 @@ require "CGI.pl"; # Use the global template variables. use vars qw($vars $template); -ConnectToDatabase(); - -quietly_check_login(); +Bugzilla->login(); my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/doeditparams.cgi b/mozilla/webtools/bugzilla/doeditparams.cgi index 4799c99c085..679bd74e3ff 100755 --- a/mozilla/webtools/bugzilla/doeditparams.cgi +++ b/mozilla/webtools/bugzilla/doeditparams.cgi @@ -26,12 +26,12 @@ use strict; use lib qw(.); use Bugzilla; +use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT :admin $datadir); require "CGI.pl"; -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/duplicates.cgi b/mozilla/webtools/bugzilla/duplicates.cgi index aa627fc4017..b45bd271062 100755 --- a/mozilla/webtools/bugzilla/duplicates.cgi +++ b/mozilla/webtools/bugzilla/duplicates.cgi @@ -54,7 +54,6 @@ if (defined $cgi->param('ctype') && $cgi->param('ctype') eq "xul") { # Use global templatisation variables. use vars qw($template $vars); -ConnectToDatabase(); GetVersionTable(); # collectstats.pl uses duplicates.cgi to generate the RDF duplicates stats. @@ -64,7 +63,7 @@ if ($::ENV{'GATEWAY_INTERFACE'} eq "cmdline") { Bugzilla->login(LOGIN_OPTIONAL); } else { - Bugzilla->login(LOGIN_NORMAL); + Bugzilla->login(); } Bugzilla->switch_to_shadow_db(); diff --git a/mozilla/webtools/bugzilla/editcomponents.cgi b/mozilla/webtools/bugzilla/editcomponents.cgi index 1cac27a991a..5ed7a28d705 100755 --- a/mozilla/webtools/bugzilla/editcomponents.cgi +++ b/mozilla/webtools/bugzilla/editcomponents.cgi @@ -31,6 +31,7 @@ use lib "."; require "CGI.pl"; require "globals.pl"; +use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Series; @@ -195,8 +196,7 @@ sub PutTrailer (@) # Preliminary checks: # -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); print Bugzilla->cgi->header(); diff --git a/mozilla/webtools/bugzilla/editflagtypes.cgi b/mozilla/webtools/bugzilla/editflagtypes.cgi index 711828b6a76..5fcabd73fd5 100755 --- a/mozilla/webtools/bugzilla/editflagtypes.cgi +++ b/mozilla/webtools/bugzilla/editflagtypes.cgi @@ -31,18 +31,16 @@ use lib "."; # Include the Bugzilla CGI and general utility library. require "CGI.pl"; -# Establish a connection to the database backend. -ConnectToDatabase(); - # Use Bugzilla's flag modules for handling flag types. use Bugzilla; +use Bugzilla::Constants; use Bugzilla::Flag; use Bugzilla::FlagType; use vars qw( $template $vars ); # Make sure the user is logged in and is an administrator. -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); UserInGroup("editcomponents") || ThrowUserError("authorization_failure", { action => "administer flag types" }); diff --git a/mozilla/webtools/bugzilla/editgroups.cgi b/mozilla/webtools/bugzilla/editgroups.cgi index e9654576884..4f97972b300 100755 --- a/mozilla/webtools/bugzilla/editgroups.cgi +++ b/mozilla/webtools/bugzilla/editgroups.cgi @@ -34,8 +34,7 @@ require "CGI.pl"; use vars qw($template $vars); -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); print Bugzilla->cgi->header(); diff --git a/mozilla/webtools/bugzilla/editkeywords.cgi b/mozilla/webtools/bugzilla/editkeywords.cgi index 0069886cd3d..0083f8ee9ba 100755 --- a/mozilla/webtools/bugzilla/editkeywords.cgi +++ b/mozilla/webtools/bugzilla/editkeywords.cgi @@ -25,6 +25,7 @@ use lib "."; require "CGI.pl"; +use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT $datadir); my $cgi = Bugzilla->cgi; @@ -53,8 +54,7 @@ sub Validate ($$) { # Preliminary checks: # -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); print Bugzilla->cgi->header(); diff --git a/mozilla/webtools/bugzilla/editmilestones.cgi b/mozilla/webtools/bugzilla/editmilestones.cgi index 7a77de155d9..e707cf46d7a 100755 --- a/mozilla/webtools/bugzilla/editmilestones.cgi +++ b/mozilla/webtools/bugzilla/editmilestones.cgi @@ -19,6 +19,7 @@ use lib "."; require "CGI.pl"; require "globals.pl"; +use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT $datadir); # TestProduct: just returns if the specified product does exists @@ -144,8 +145,7 @@ sub PutTrailer (@) # Preliminary checks: # -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); print Bugzilla->cgi->header(); diff --git a/mozilla/webtools/bugzilla/editparams.cgi b/mozilla/webtools/bugzilla/editparams.cgi index dd61e954377..aaa2b087af4 100755 --- a/mozilla/webtools/bugzilla/editparams.cgi +++ b/mozilla/webtools/bugzilla/editparams.cgi @@ -25,12 +25,12 @@ use strict; use lib "."; +use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT :admin); require "CGI.pl"; -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); print Bugzilla->cgi->header(); diff --git a/mozilla/webtools/bugzilla/editproducts.cgi b/mozilla/webtools/bugzilla/editproducts.cgi index f5377950179..051fdb86c5c 100755 --- a/mozilla/webtools/bugzilla/editproducts.cgi +++ b/mozilla/webtools/bugzilla/editproducts.cgi @@ -179,8 +179,7 @@ sub PutTrailer (@) # Preliminary checks: # -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); print Bugzilla->cgi->header(); diff --git a/mozilla/webtools/bugzilla/editusers.cgi b/mozilla/webtools/bugzilla/editusers.cgi index e7ef0e7d30f..3db5aef8632 100755 --- a/mozilla/webtools/bugzilla/editusers.cgi +++ b/mozilla/webtools/bugzilla/editusers.cgi @@ -36,6 +36,7 @@ require "globals.pl"; use Bugzilla; use Bugzilla::User; +use Bugzilla::Constants; # Shut up misguided -w warnings about "used only once". "use vars" just # doesn't work for me. @@ -238,8 +239,7 @@ sub PutTrailer (@) # Preliminary checks: # -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); print Bugzilla->cgi->header(); diff --git a/mozilla/webtools/bugzilla/editversions.cgi b/mozilla/webtools/bugzilla/editversions.cgi index 9c4a5e5ea75..527f42aafe4 100755 --- a/mozilla/webtools/bugzilla/editversions.cgi +++ b/mozilla/webtools/bugzilla/editversions.cgi @@ -32,6 +32,7 @@ use lib "."; require "CGI.pl"; require "globals.pl"; +use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT $datadir); # TestProduct: just returns if the specified product does exists @@ -153,8 +154,7 @@ sub PutTrailer (@) # Preliminary checks: # -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); print Bugzilla->cgi->header(); diff --git a/mozilla/webtools/bugzilla/enter_bug.cgi b/mozilla/webtools/bugzilla/enter_bug.cgi index eca672a45b9..1dd02c90c44 100755 --- a/mozilla/webtools/bugzilla/enter_bug.cgi +++ b/mozilla/webtools/bugzilla/enter_bug.cgi @@ -57,20 +57,15 @@ use vars qw( $proddesc ); -# We have to connect to the database, even though we don't use it in this code, -# because we might occasionally rebuild the version cache, which causes tokens -# to get deleted from the database, which needs a database connection. -ConnectToDatabase(); - # If we're using bug groups to restrict bug entry, we need to know who the # user is right from the start. -confirm_login() if AnyEntryGroups(); +Bugzilla->login(LOGIN_REQUIRED) if AnyEntryGroups(); my $cgi = Bugzilla->cgi; if (!defined $::FORM{'product'}) { GetVersionTable(); - quietly_check_login(); + Bugzilla->login(); my %products; @@ -225,7 +220,7 @@ sub pickos { # End of subroutines ############################################################################## -confirm_login() if (!(AnyEntryGroups())); +Bugzilla->login(LOGIN_REQUIRED) if (!(AnyEntryGroups())); # We need to check and make sure # that the user has permission to enter a bug against this product. diff --git a/mozilla/webtools/bugzilla/importxml.pl b/mozilla/webtools/bugzilla/importxml.pl index 5b0599e988c..f233871765d 100755 --- a/mozilla/webtools/bugzilla/importxml.pl +++ b/mozilla/webtools/bugzilla/importxml.pl @@ -71,7 +71,6 @@ require "CGI.pl"; require "globals.pl"; $::lockcount = 0; -ConnectToDatabase(); GetVersionTable(); diff --git a/mozilla/webtools/bugzilla/index.cgi b/mozilla/webtools/bugzilla/index.cgi index bbe936207f0..88393b41787 100755 --- a/mozilla/webtools/bugzilla/index.cgi +++ b/mozilla/webtools/bugzilla/index.cgi @@ -36,11 +36,9 @@ use vars qw( $vars ); -# Establish a connection to the database backend. -ConnectToDatabase(); - # Check whether or not the user is logged in and, if so, set the $::userid -quietly_check_login('permit_anonymous'); +use Bugzilla::Constants; +Bugzilla->login(LOGIN_OPTIONAL); ############################################################################### # Main Body Execution diff --git a/mozilla/webtools/bugzilla/long_list.cgi b/mozilla/webtools/bugzilla/long_list.cgi index 72c579ac4dc..657ff9e24f0 100755 --- a/mozilla/webtools/bugzilla/long_list.cgi +++ b/mozilla/webtools/bugzilla/long_list.cgi @@ -33,9 +33,7 @@ use vars qw($userid @legal_keywords); # Use global template variables. use vars qw($template $vars); -ConnectToDatabase(); - -quietly_check_login(); +Bugzilla->login(); GetVersionTable(); diff --git a/mozilla/webtools/bugzilla/move.pl b/mozilla/webtools/bugzilla/move.pl index b4d47a40fc3..99ed585f329 100755 --- a/mozilla/webtools/bugzilla/move.pl +++ b/mozilla/webtools/bugzilla/move.pl @@ -31,6 +31,7 @@ require "CGI.pl"; use vars qw($template $userid %COOKIE); use Bugzilla; +use Bugzilla::Constants; use Bugzilla::Bug; use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::BugMail; @@ -43,8 +44,7 @@ unless ( Param("move-enabled") ) { exit; } -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/page.cgi b/mozilla/webtools/bugzilla/page.cgi index 91027ff4f77..b68a9313b48 100755 --- a/mozilla/webtools/bugzilla/page.cgi +++ b/mozilla/webtools/bugzilla/page.cgi @@ -38,9 +38,7 @@ require "CGI.pl"; use vars qw($template $vars); -ConnectToDatabase(); - -quietly_check_login(); +Bugzilla->login(); my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/post_bug.cgi b/mozilla/webtools/bugzilla/post_bug.cgi index d6fda9b3bfc..800b46f0165 100755 --- a/mozilla/webtools/bugzilla/post_bug.cgi +++ b/mozilla/webtools/bugzilla/post_bug.cgi @@ -53,8 +53,7 @@ sub sillyness { # Use global template variables. use vars qw($vars $template); -ConnectToDatabase(); -my $user = confirm_login(); +my $user = Bugzilla->login(LOGIN_REQUIRED); my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/process_bug.cgi b/mozilla/webtools/bugzilla/process_bug.cgi index 4df90efd2fc..e54a4696573 100755 --- a/mozilla/webtools/bugzilla/process_bug.cgi +++ b/mozilla/webtools/bugzilla/process_bug.cgi @@ -55,8 +55,7 @@ use vars qw(%versions %legal_severity ); -ConnectToDatabase(); -my $user = confirm_login(); +my $user = Bugzilla->login(LOGIN_REQUIRED); my $whoid = $user->id; my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/query.cgi b/mozilla/webtools/bugzilla/query.cgi index 7786da96bd1..a37fc91256c 100755 --- a/mozilla/webtools/bugzilla/query.cgi +++ b/mozilla/webtools/bugzilla/query.cgi @@ -28,6 +28,8 @@ use lib "."; require "CGI.pl"; +use Bugzilla::Constants; + use vars qw( @CheckOptionValues @legal_resolution @@ -49,16 +51,14 @@ use vars qw( $vars ); -ConnectToDatabase(); - my $cgi = Bugzilla->cgi; if (defined $::FORM{"GoAheadAndLogIn"}) { # We got here from a login page, probably from relogin.cgi. We better # make sure the password is legit. - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); } else { - quietly_check_login(); + Bugzilla->login(); } my $user = Bugzilla->user; diff --git a/mozilla/webtools/bugzilla/queryhelp.cgi b/mozilla/webtools/bugzilla/queryhelp.cgi index 60ebdd120f2..361ebc38286 100755 --- a/mozilla/webtools/bugzilla/queryhelp.cgi +++ b/mozilla/webtools/bugzilla/queryhelp.cgi @@ -28,8 +28,7 @@ use lib qw(.); require "CGI.pl"; -ConnectToDatabase(); -quietly_check_login(); +Bugzilla->login(); GetVersionTable(); diff --git a/mozilla/webtools/bugzilla/quips.cgi b/mozilla/webtools/bugzilla/quips.cgi index bf1c41450de..9bb6ea43a2c 100755 --- a/mozilla/webtools/bugzilla/quips.cgi +++ b/mozilla/webtools/bugzilla/quips.cgi @@ -36,8 +36,9 @@ use lib qw(.); require "CGI.pl"; -ConnectToDatabase(); -confirm_login(); +use Bugzilla::Constants; + +Bugzilla->login(LOGIN_REQUIRED); my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/relogin.cgi b/mozilla/webtools/bugzilla/relogin.cgi index b7ba4f61e33..6843405c20e 100755 --- a/mozilla/webtools/bugzilla/relogin.cgi +++ b/mozilla/webtools/bugzilla/relogin.cgi @@ -30,11 +30,9 @@ use lib qw(.); require "CGI.pl"; # We don't want to remove a random logincookie from the db, so -# call quietly_check_login. If we're logged in after this, then +# call Bugzilla->login(). If we're logged in after this, then # the logincookie must be correct - -ConnectToDatabase(); -quietly_check_login(); +Bugzilla->login(); Bugzilla->logout(); diff --git a/mozilla/webtools/bugzilla/report.cgi b/mozilla/webtools/bugzilla/report.cgi index 2c0c430a932..cb872fc5bc7 100755 --- a/mozilla/webtools/bugzilla/report.cgi +++ b/mozilla/webtools/bugzilla/report.cgi @@ -29,6 +29,7 @@ require "CGI.pl"; use vars qw($template $vars); use Bugzilla; +use Bugzilla::Constants; my $cgi = Bugzilla->cgi; @@ -44,11 +45,9 @@ if (grep(/^cmd-/, $cgi->param())) { use Bugzilla::Search; -ConnectToDatabase(); - GetVersionTable(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); Bugzilla->switch_to_shadow_db(); diff --git a/mozilla/webtools/bugzilla/reports.cgi b/mozilla/webtools/bugzilla/reports.cgi index b863249d6ff..01ce9927724 100755 --- a/mozilla/webtools/bugzilla/reports.cgi +++ b/mozilla/webtools/bugzilla/reports.cgi @@ -56,8 +56,7 @@ use Bugzilla; # If we're using bug groups for products, we should apply those restrictions # to viewing reports, as well. Time to check the login in that case. -ConnectToDatabase(); -quietly_check_login(); +Bugzilla->login(); GetVersionTable(); diff --git a/mozilla/webtools/bugzilla/request.cgi b/mozilla/webtools/bugzilla/request.cgi index 90304a2b920..43be6985633 100755 --- a/mozilla/webtools/bugzilla/request.cgi +++ b/mozilla/webtools/bugzilla/request.cgi @@ -31,9 +31,6 @@ use strict; use lib qw(.); require "CGI.pl"; -# Establish a connection to the database backend. -ConnectToDatabase(); - # Use Bugzilla's Request module which contains utilities for handling requests. use Bugzilla::Flag; use Bugzilla::FlagType; @@ -44,7 +41,7 @@ use Bugzilla::User; use vars qw($template $vars @legal_product @legal_components %components); # Make sure the user is logged in. -quietly_check_login(); +Bugzilla->login(); ################################################################################ # Main Body Execution diff --git a/mozilla/webtools/bugzilla/sanitycheck.cgi b/mozilla/webtools/bugzilla/sanitycheck.cgi index 8060c1c9974..51b49902522 100755 --- a/mozilla/webtools/bugzilla/sanitycheck.cgi +++ b/mozilla/webtools/bugzilla/sanitycheck.cgi @@ -70,9 +70,7 @@ sub BugListLinks { # Start ########################################################################### -ConnectToDatabase(); - -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/show_activity.cgi b/mozilla/webtools/bugzilla/show_activity.cgi index e1697255b70..5ab4e366e69 100755 --- a/mozilla/webtools/bugzilla/show_activity.cgi +++ b/mozilla/webtools/bugzilla/show_activity.cgi @@ -30,14 +30,12 @@ use vars qw ($template $vars); require "CGI.pl"; my $cgi = Bugzilla->cgi; -ConnectToDatabase(); - ############################################################################### # Begin Data/Security Validation ############################################################################### # Check whether or not the user is currently logged in. -quietly_check_login(); +Bugzilla->login(); # Make sure the bug ID is a positive integer representing an existing # bug that the user is authorized to access. diff --git a/mozilla/webtools/bugzilla/show_bug.cgi b/mozilla/webtools/bugzilla/show_bug.cgi index 6d971bbfcc7..4b2459f90da 100755 --- a/mozilla/webtools/bugzilla/show_bug.cgi +++ b/mozilla/webtools/bugzilla/show_bug.cgi @@ -25,11 +25,10 @@ use strict; use lib qw(.); use Bugzilla; +use Bugzilla::Constants; require "CGI.pl"; -ConnectToDatabase(); - use vars qw($template $vars $userid); use Bugzilla::Bug; @@ -37,9 +36,9 @@ use Bugzilla::Bug; my $cgi = Bugzilla->cgi; if ($::FORM{'GoAheadAndLogIn'}) { - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); } else { - quietly_check_login(); + Bugzilla->login(); } # Editable, 'single' HTML bugs are treated slightly specially in a few places diff --git a/mozilla/webtools/bugzilla/showdependencygraph.cgi b/mozilla/webtools/bugzilla/showdependencygraph.cgi index a863df14204..e0bd376d55d 100755 --- a/mozilla/webtools/bugzilla/showdependencygraph.cgi +++ b/mozilla/webtools/bugzilla/showdependencygraph.cgi @@ -31,9 +31,7 @@ use Bugzilla::Config qw(:DEFAULT $webdotdir); require "CGI.pl"; -ConnectToDatabase(); - -quietly_check_login(); +Bugzilla->login(); my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/showdependencytree.cgi b/mozilla/webtools/bugzilla/showdependencytree.cgi index b82443226e5..202043acdc5 100755 --- a/mozilla/webtools/bugzilla/showdependencytree.cgi +++ b/mozilla/webtools/bugzilla/showdependencytree.cgi @@ -31,9 +31,7 @@ require "CGI.pl"; # Use global template variables. use vars qw($template $vars); -ConnectToDatabase(); - -quietly_check_login(); +Bugzilla->login(); my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/sidebar.cgi b/mozilla/webtools/bugzilla/sidebar.cgi index cf801eba333..73a22d1b339 100755 --- a/mozilla/webtools/bugzilla/sidebar.cgi +++ b/mozilla/webtools/bugzilla/sidebar.cgi @@ -26,8 +26,7 @@ use vars qw( $vars ); -ConnectToDatabase(); -quietly_check_login(); +Bugzilla->login(); my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/token.cgi b/mozilla/webtools/bugzilla/token.cgi index 697da39b18a..36508f0a538 100755 --- a/mozilla/webtools/bugzilla/token.cgi +++ b/mozilla/webtools/bugzilla/token.cgi @@ -32,14 +32,14 @@ use lib qw(.); use vars qw($template $vars); use Bugzilla; +use Bugzilla::Constants; + my $cgi = Bugzilla->cgi; # Include the Bugzilla CGI and general utility library. require "CGI.pl"; -# Establish a connection to the database backend. -ConnectToDatabase(); -quietly_check_login('permit_anonymous'); +Bugzilla->login(LOGIN_OPTIONAL); # Use the "Bugzilla::Token" module that contains functions for doing various # token-related tasks. diff --git a/mozilla/webtools/bugzilla/userprefs.cgi b/mozilla/webtools/bugzilla/userprefs.cgi index 15afdb21c19..eefe40205b9 100755 --- a/mozilla/webtools/bugzilla/userprefs.cgi +++ b/mozilla/webtools/bugzilla/userprefs.cgi @@ -308,8 +308,7 @@ sub DoSavedSearches() { # Live code (not subroutine definitions) starts here ############################################################################### -ConnectToDatabase(); -confirm_login(); +Bugzilla->login(LOGIN_REQUIRED); GetVersionTable(); diff --git a/mozilla/webtools/bugzilla/votes.cgi b/mozilla/webtools/bugzilla/votes.cgi index ed7f6ad5197..937149b3d69 100755 --- a/mozilla/webtools/bugzilla/votes.cgi +++ b/mozilla/webtools/bugzilla/votes.cgi @@ -27,14 +27,13 @@ use strict; use lib "."; use Bugzilla; +use Bugzilla::Constants; require "CGI.pl"; # Use global template variables use vars qw($template $vars); -ConnectToDatabase(); - my $cgi = Bugzilla->cgi; # If the action is show_bug, you need a bug_id. @@ -51,10 +50,10 @@ my $action = $::FORM{'action'} || if ($action eq "show_bug" || ($action eq "show_user" && defined($::FORM{'user'}))) { - quietly_check_login(); + Bugzilla->login(); } else { - confirm_login(); + Bugzilla->login(LOGIN_REQUIRED); } ################################################################################ diff --git a/mozilla/webtools/bugzilla/whineatnews.pl b/mozilla/webtools/bugzilla/whineatnews.pl index 57a82358300..b5fd020a9fa 100755 --- a/mozilla/webtools/bugzilla/whineatnews.pl +++ b/mozilla/webtools/bugzilla/whineatnews.pl @@ -31,8 +31,6 @@ use strict; require "globals.pl"; -ConnectToDatabase(); - SendSQL("select bug_id,short_desc,login_name from bugs,profiles where " . "(bug_status = 'NEW' or bug_status = 'REOPENED') and " . "to_days(now()) - to_days(delta_ts) > " . Param('whinedays') .