Commit 4df1c8fd authored by kiko%async.com.br's avatar kiko%async.com.br

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 <wicked@etlicon.fi>. r=bbaetz, kiko. a=justdave.
parent 3374c87e
...@@ -33,7 +33,7 @@ use base qw(Exporter); ...@@ -33,7 +33,7 @@ use base qw(Exporter);
%Bugzilla::DB::EXPORT_TAGS = %Bugzilla::DB::EXPORT_TAGS =
( (
deprecated => [qw(ConnectToDatabase SendSQL SqlQuote deprecated => [qw(SendSQL SqlQuote
MoreSQLData FetchSQLData FetchOneColumn MoreSQLData FetchSQLData FetchOneColumn
PushGlobalSQLState PopGlobalSQLState) PushGlobalSQLState PopGlobalSQLState)
], ],
...@@ -49,10 +49,6 @@ use Bugzilla::Util; ...@@ -49,10 +49,6 @@ use Bugzilla::Util;
# having a separate package for it, or otherwise trying to avoid the circular # having a separate package for it, or otherwise trying to avoid the circular
# dependancy # dependancy
sub ConnectToDatabase {
# We've already been connected in Bugzilla.pm
}
# XXX - mod_perl # XXX - mod_perl
# These use |our| instead of |my| because they need to be cleared from # These use |our| instead of |my| because they need to be cleared from
# Bugzilla.pm. See bug 192531 for details. # Bugzilla.pm. See bug 192531 for details.
...@@ -222,10 +218,6 @@ and so are not documented. ...@@ -222,10 +218,6 @@ and so are not documented.
=item * =item *
ConnectToDatabase
=item *
SendSQL SendSQL
=item * =item *
......
...@@ -198,10 +198,6 @@ sub PasswordForLogin { ...@@ -198,10 +198,6 @@ sub PasswordForLogin {
return $result; return $result;
} }
sub quietly_check_login {
return Bugzilla->login($_[0] ? LOGIN_OPTIONAL : LOGIN_NORMAL);
}
sub CheckEmailSyntax { sub CheckEmailSyntax {
my ($addr) = (@_); my ($addr) = (@_);
my $match = Param('emailregexp'); my $match = Param('emailregexp');
...@@ -224,10 +220,6 @@ sub MailPassword { ...@@ -224,10 +220,6 @@ sub MailPassword {
close SENDMAIL; close SENDMAIL;
} }
sub confirm_login {
return Bugzilla->login(LOGIN_REQUIRED);
}
sub PutHeader { sub PutHeader {
($vars->{'title'}, $vars->{'h1'}, $vars->{'h2'}) = (@_); ($vars->{'title'}, $vars->{'h1'}, $vars->{'h2'}) = (@_);
......
...@@ -42,16 +42,14 @@ use vars qw( ...@@ -42,16 +42,14 @@ use vars qw(
require "CGI.pl"; require "CGI.pl";
# Use these modules to handle flags. # Use these modules to handle flags.
use Bugzilla::Constants;
use Bugzilla::Flag; use Bugzilla::Flag;
use Bugzilla::FlagType; use Bugzilla::FlagType;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Util; 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 # 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 # 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 # by validateID() (which validates the attachment ID, not the bug ID, but has
...@@ -104,14 +102,14 @@ elsif ($action eq "viewall") ...@@ -104,14 +102,14 @@ elsif ($action eq "viewall")
} }
elsif ($action eq "enter") elsif ($action eq "enter")
{ {
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
ValidateBugID($::FORM{'bugid'}); ValidateBugID($::FORM{'bugid'});
validateCanChangeBug($::FORM{'bugid'}); validateCanChangeBug($::FORM{'bugid'});
enter(); enter();
} }
elsif ($action eq "insert") elsif ($action eq "insert")
{ {
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
ValidateBugID($::FORM{'bugid'}); ValidateBugID($::FORM{'bugid'});
validateCanChangeBug($::FORM{'bugid'}); validateCanChangeBug($::FORM{'bugid'});
ValidateComment($::FORM{'comment'}); ValidateComment($::FORM{'comment'});
...@@ -125,14 +123,13 @@ elsif ($action eq "insert") ...@@ -125,14 +123,13 @@ elsif ($action eq "insert")
} }
elsif ($action eq "edit") elsif ($action eq "edit")
{ {
quietly_check_login();
validateID(); validateID();
validateCanEdit($::FORM{'id'}); validateCanEdit($::FORM{'id'});
edit(); edit();
} }
elsif ($action eq "update") elsif ($action eq "update")
{ {
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
ValidateComment($::FORM{'comment'}); ValidateComment($::FORM{'comment'});
validateID(); validateID();
validateCanEdit($::FORM{'id'}); validateCanEdit($::FORM{'id'});
...@@ -216,9 +213,10 @@ sub validateCanEdit ...@@ -216,9 +213,10 @@ sub validateCanEdit
my ($attach_id) = (@_); my ($attach_id) = (@_);
# If the user is not logged in, claim that they can edit. This allows # 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 # 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; return if $::userid == 0;
# People in editbugs can edit all attachments # People in editbugs can edit all attachments
......
...@@ -37,6 +37,7 @@ use vars qw($template $vars); ...@@ -37,6 +37,7 @@ use vars qw($template $vars);
use Bugzilla; use Bugzilla;
use Bugzilla::Search; use Bugzilla::Search;
use Bugzilla::Constants;
# Include the Bugzilla CGI and general utility library. # Include the Bugzilla CGI and general utility library.
require "CGI.pl"; require "CGI.pl";
...@@ -63,8 +64,6 @@ if (length($::buffer) == 0) { ...@@ -63,8 +64,6 @@ if (length($::buffer) == 0) {
ThrowUserError("buglist_parameters_required"); ThrowUserError("buglist_parameters_required");
} }
ConnectToDatabase();
################################################################################ ################################################################################
# Data and Security Validation # Data and Security Validation
################################################################################ ################################################################################
...@@ -74,12 +73,12 @@ my $dotweak = $::FORM{'tweak'} ? 1 : 0; ...@@ -74,12 +73,12 @@ my $dotweak = $::FORM{'tweak'} ? 1 : 0;
# Log the user in # Log the user in
if ($dotweak) { if ($dotweak) {
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
UserInGroup("editbugs") || ThrowUserError("insufficient_privs_for_multi"); UserInGroup("editbugs") || ThrowUserError("insufficient_privs_for_multi");
GetVersionTable(); GetVersionTable();
} }
else { else {
quietly_check_login(); Bugzilla->login();
} }
# Hack to support legacy applications that think the RDF ctype is at format=rdf. # Hack to support legacy applications that think the RDF ctype is at format=rdf.
...@@ -182,7 +181,7 @@ sub iCalendarDateTime { ...@@ -182,7 +181,7 @@ sub iCalendarDateTime {
sub LookupNamedQuery { sub LookupNamedQuery {
my ($name) = @_; my ($name) = @_;
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"}); my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"});
my $qname = SqlQuote($name); my $qname = SqlQuote($name);
SendSQL("SELECT query FROM namedqueries WHERE userid = $userid AND name = $qname"); SendSQL("SELECT query FROM namedqueries WHERE userid = $userid AND name = $qname");
...@@ -305,7 +304,7 @@ if ($::FORM{'cmdtype'} eq "dorem") { ...@@ -305,7 +304,7 @@ if ($::FORM{'cmdtype'} eq "dorem") {
$order = $params->param('order') || $order; $order = $params->param('order') || $order;
} }
elsif ($::FORM{'remaction'} eq "forget") { elsif ($::FORM{'remaction'} eq "forget") {
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"}); my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"});
my $qname = SqlQuote($::FORM{'namedcmd'}); my $qname = SqlQuote($::FORM{'namedcmd'});
SendSQL("DELETE FROM namedqueries WHERE userid = $userid AND name = $qname"); SendSQL("DELETE FROM namedqueries WHERE userid = $userid AND name = $qname");
...@@ -325,7 +324,7 @@ if ($::FORM{'cmdtype'} eq "dorem") { ...@@ -325,7 +324,7 @@ if ($::FORM{'cmdtype'} eq "dorem") {
} }
elsif (($::FORM{'cmdtype'} eq "doit") && $::FORM{'remtype'}) { elsif (($::FORM{'cmdtype'} eq "doit") && $::FORM{'remtype'}) {
if ($::FORM{'remtype'} eq "asdefault") { if ($::FORM{'remtype'} eq "asdefault") {
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"}); my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"});
my $qname = SqlQuote($::defaultqueryname); my $qname = SqlQuote($::defaultqueryname);
my $qbuffer = SqlQuote($::buffer); my $qbuffer = SqlQuote($::buffer);
...@@ -335,7 +334,7 @@ elsif (($::FORM{'cmdtype'} eq "doit") && $::FORM{'remtype'}) { ...@@ -335,7 +334,7 @@ elsif (($::FORM{'cmdtype'} eq "doit") && $::FORM{'remtype'}) {
$vars->{'message'} = "buglist_new_default_query"; $vars->{'message'} = "buglist_new_default_query";
} }
elsif ($::FORM{'remtype'} eq "asnamed") { elsif ($::FORM{'remtype'} eq "asnamed") {
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"}); my $userid = DBNameToIdAndCheck($::COOKIE{"Bugzilla_login"});
my $name = trim($::FORM{'newqueryname'}); my $name = trim($::FORM{'newqueryname'});
......
...@@ -45,6 +45,7 @@ use strict; ...@@ -45,6 +45,7 @@ use strict;
use lib qw(.); use lib qw(.);
require "CGI.pl"; require "CGI.pl";
use Bugzilla::Constants;
use Bugzilla::Chart; use Bugzilla::Chart;
use Bugzilla::Series; use Bugzilla::Series;
...@@ -81,9 +82,7 @@ if ($action eq "search") { ...@@ -81,9 +82,7 @@ if ($action eq "search") {
exit; exit;
} }
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
# Only admins may create public queries # Only admins may create public queries
UserInGroup('admin') || $cgi->delete('public'); UserInGroup('admin') || $cgi->delete('public');
......
...@@ -36,8 +36,7 @@ use Bugzilla; ...@@ -36,8 +36,7 @@ use Bugzilla;
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase(); Bugzilla->login();
quietly_check_login();
GetVersionTable(); GetVersionTable();
......
...@@ -51,7 +51,6 @@ if (chdir("graphs")) { ...@@ -51,7 +51,6 @@ if (chdir("graphs")) {
chdir(".."); chdir("..");
} }
ConnectToDatabase();
GetVersionTable(); GetVersionTable();
Bugzilla->switch_to_shadow_db(); Bugzilla->switch_to_shadow_db();
......
...@@ -33,10 +33,6 @@ use strict; ...@@ -33,10 +33,6 @@ use strict;
use lib qw(.); use lib qw(.);
require "CGI.pl"; 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. # Retrieve this installation's configuration.
GetVersionTable(); GetVersionTable();
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
# #
# You need to work with bug_email.pl the MIME::Parser installed. # 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) # 02/12/2000 (SML)
...@@ -746,8 +746,6 @@ die (" *** Cant find Sender-adress in sent mail ! ***\n" ) unless defined( $Send ...@@ -746,8 +746,6 @@ die (" *** Cant find Sender-adress in sent mail ! ***\n" ) unless defined( $Send
chomp( $Sender ); chomp( $Sender );
chomp( $Message_ID ); chomp( $Message_ID );
ConnectToDatabase();
$SenderShort = $Sender; $SenderShort = $Sender;
$SenderShort =~ s/^.*?([a-zA-Z0-9_.-]+?\@[a-zA-Z0-9_.-]+\.[a-zA-Z0-9_.-]+).*$/$1/; $SenderShort =~ s/^.*?([a-zA-Z0-9_.-]+?\@[a-zA-Z0-9_.-]+\.[a-zA-Z0-9_.-]+).*$/$1/;
......
...@@ -68,8 +68,6 @@ chomp( $Message_ID ); ...@@ -68,8 +68,6 @@ chomp( $Message_ID );
print "Dealing with the sender $Sender\n"; print "Dealing with the sender $Sender\n";
ConnectToDatabase();
my $SenderShort = $Sender; my $SenderShort = $Sender;
$SenderShort =~ s/^.*?([a-zA-Z0-9_.-]+?\@[a-zA-Z0-9_.-]+\.[a-zA-Z0-9_.-]+).*$/$1/; $SenderShort =~ s/^.*?([a-zA-Z0-9_.-]+?\@[a-zA-Z0-9_.-]+\.[a-zA-Z0-9_.-]+).*$/$1/;
......
...@@ -74,8 +74,6 @@ foreach my $arg (@ARGV) ...@@ -74,8 +74,6 @@ foreach my $arg (@ARGV)
} }
} }
ConnectToDatabase();
my %bugzilla_users; my %bugzilla_users;
my %ldap_users; my %ldap_users;
......
...@@ -36,13 +36,11 @@ use vars qw( ...@@ -36,13 +36,11 @@ use vars qw(
$vars $vars
); );
ConnectToDatabase();
# If we're using LDAP for login, then we can't create a new account here. # If we're using LDAP for login, then we can't create a new account here.
unless (Bugzilla::Auth->can_edit) { unless (Bugzilla::Auth->can_edit) {
# Just in case someone already has an account, let them get the correct # Just in case someone already has an account, let them get the correct
# footer on the error message # footer on the error message
quietly_check_login(); Bugzilla->login();
ThrowUserError("auth_cant_create_account"); ThrowUserError("auth_cant_create_account");
} }
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
use vars qw( use vars qw(
%legal_product %legal_product
$userid
); );
use strict; use strict;
...@@ -31,11 +30,11 @@ use strict; ...@@ -31,11 +30,11 @@ use strict;
use lib qw(.); use lib qw(.);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants;
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase(); Bugzilla->login();
quietly_check_login();
GetVersionTable(); GetVersionTable();
...@@ -48,7 +47,7 @@ if (!defined $product) { ...@@ -48,7 +47,7 @@ if (!defined $product) {
if (AnyEntryGroups()) { if (AnyEntryGroups()) {
# OK, now only add products the user can see # 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) { foreach my $p (@::legal_product) {
if (CanEnterProduct($p)) { if (CanEnterProduct($p)) {
$products{$p} = $::proddesc{$p}; $products{$p} = $::proddesc{$p};
......
...@@ -31,9 +31,7 @@ require "CGI.pl"; ...@@ -31,9 +31,7 @@ require "CGI.pl";
# Use the global template variables. # Use the global template variables.
use vars qw($vars $template); use vars qw($vars $template);
ConnectToDatabase(); Bugzilla->login();
quietly_check_login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -26,12 +26,12 @@ use strict; ...@@ -26,12 +26,12 @@ use strict;
use lib qw(.); use lib qw(.);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT :admin $datadir); use Bugzilla::Config qw(:DEFAULT :admin $datadir);
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -54,7 +54,6 @@ if (defined $cgi->param('ctype') && $cgi->param('ctype') eq "xul") { ...@@ -54,7 +54,6 @@ if (defined $cgi->param('ctype') && $cgi->param('ctype') eq "xul") {
# Use global templatisation variables. # Use global templatisation variables.
use vars qw($template $vars); use vars qw($template $vars);
ConnectToDatabase();
GetVersionTable(); GetVersionTable();
# collectstats.pl uses duplicates.cgi to generate the RDF duplicates stats. # collectstats.pl uses duplicates.cgi to generate the RDF duplicates stats.
...@@ -64,7 +63,7 @@ if ($::ENV{'GATEWAY_INTERFACE'} eq "cmdline") { ...@@ -64,7 +63,7 @@ if ($::ENV{'GATEWAY_INTERFACE'} eq "cmdline") {
Bugzilla->login(LOGIN_OPTIONAL); Bugzilla->login(LOGIN_OPTIONAL);
} }
else { else {
Bugzilla->login(LOGIN_NORMAL); Bugzilla->login();
} }
Bugzilla->switch_to_shadow_db(); Bugzilla->switch_to_shadow_db();
......
...@@ -31,6 +31,7 @@ use lib "."; ...@@ -31,6 +31,7 @@ use lib ".";
require "CGI.pl"; require "CGI.pl";
require "globals.pl"; require "globals.pl";
use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::Series; use Bugzilla::Series;
...@@ -195,8 +196,7 @@ sub PutTrailer (@) ...@@ -195,8 +196,7 @@ sub PutTrailer (@)
# Preliminary checks: # Preliminary checks:
# #
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
print Bugzilla->cgi->header(); print Bugzilla->cgi->header();
......
...@@ -31,18 +31,16 @@ use lib "."; ...@@ -31,18 +31,16 @@ use lib ".";
# Include the Bugzilla CGI and general utility library. # Include the Bugzilla CGI and general utility library.
require "CGI.pl"; require "CGI.pl";
# Establish a connection to the database backend.
ConnectToDatabase();
# Use Bugzilla's flag modules for handling flag types. # Use Bugzilla's flag modules for handling flag types.
use Bugzilla; use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Flag; use Bugzilla::Flag;
use Bugzilla::FlagType; use Bugzilla::FlagType;
use vars qw( $template $vars ); use vars qw( $template $vars );
# Make sure the user is logged in and is an administrator. # Make sure the user is logged in and is an administrator.
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
UserInGroup("editcomponents") UserInGroup("editcomponents")
|| ThrowUserError("authorization_failure", || ThrowUserError("authorization_failure",
{ action => "administer flag types" }); { action => "administer flag types" });
......
...@@ -34,8 +34,7 @@ require "CGI.pl"; ...@@ -34,8 +34,7 @@ require "CGI.pl";
use vars qw($template $vars); use vars qw($template $vars);
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
print Bugzilla->cgi->header(); print Bugzilla->cgi->header();
......
...@@ -25,6 +25,7 @@ use lib "."; ...@@ -25,6 +25,7 @@ use lib ".";
require "CGI.pl"; require "CGI.pl";
use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Config qw(:DEFAULT $datadir);
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
...@@ -53,8 +54,7 @@ sub Validate ($$) { ...@@ -53,8 +54,7 @@ sub Validate ($$) {
# Preliminary checks: # Preliminary checks:
# #
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
print Bugzilla->cgi->header(); print Bugzilla->cgi->header();
......
...@@ -19,6 +19,7 @@ use lib "."; ...@@ -19,6 +19,7 @@ use lib ".";
require "CGI.pl"; require "CGI.pl";
require "globals.pl"; require "globals.pl";
use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Config qw(:DEFAULT $datadir);
# TestProduct: just returns if the specified product does exists # TestProduct: just returns if the specified product does exists
...@@ -144,8 +145,7 @@ sub PutTrailer (@) ...@@ -144,8 +145,7 @@ sub PutTrailer (@)
# Preliminary checks: # Preliminary checks:
# #
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
print Bugzilla->cgi->header(); print Bugzilla->cgi->header();
......
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
use strict; use strict;
use lib "."; use lib ".";
use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT :admin); use Bugzilla::Config qw(:DEFAULT :admin);
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
print Bugzilla->cgi->header(); print Bugzilla->cgi->header();
......
...@@ -179,8 +179,7 @@ sub PutTrailer (@) ...@@ -179,8 +179,7 @@ sub PutTrailer (@)
# Preliminary checks: # Preliminary checks:
# #
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
print Bugzilla->cgi->header(); print Bugzilla->cgi->header();
......
...@@ -36,6 +36,7 @@ require "globals.pl"; ...@@ -36,6 +36,7 @@ require "globals.pl";
use Bugzilla; use Bugzilla;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Constants;
# Shut up misguided -w warnings about "used only once". "use vars" just # Shut up misguided -w warnings about "used only once". "use vars" just
# doesn't work for me. # doesn't work for me.
...@@ -238,8 +239,7 @@ sub PutTrailer (@) ...@@ -238,8 +239,7 @@ sub PutTrailer (@)
# Preliminary checks: # Preliminary checks:
# #
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
print Bugzilla->cgi->header(); print Bugzilla->cgi->header();
......
...@@ -32,6 +32,7 @@ use lib "."; ...@@ -32,6 +32,7 @@ use lib ".";
require "CGI.pl"; require "CGI.pl";
require "globals.pl"; require "globals.pl";
use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Config qw(:DEFAULT $datadir);
# TestProduct: just returns if the specified product does exists # TestProduct: just returns if the specified product does exists
...@@ -153,8 +154,7 @@ sub PutTrailer (@) ...@@ -153,8 +154,7 @@ sub PutTrailer (@)
# Preliminary checks: # Preliminary checks:
# #
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
print Bugzilla->cgi->header(); print Bugzilla->cgi->header();
......
...@@ -57,20 +57,15 @@ use vars qw( ...@@ -57,20 +57,15 @@ use vars qw(
$proddesc $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 # If we're using bug groups to restrict bug entry, we need to know who the
# user is right from the start. # user is right from the start.
confirm_login() if AnyEntryGroups(); Bugzilla->login(LOGIN_REQUIRED) if AnyEntryGroups();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
if (!defined $::FORM{'product'}) { if (!defined $::FORM{'product'}) {
GetVersionTable(); GetVersionTable();
quietly_check_login(); Bugzilla->login();
my %products; my %products;
...@@ -225,7 +220,7 @@ sub pickos { ...@@ -225,7 +220,7 @@ sub pickos {
# End of subroutines # End of subroutines
############################################################################## ##############################################################################
confirm_login() if (!(AnyEntryGroups())); Bugzilla->login(LOGIN_REQUIRED) if (!(AnyEntryGroups()));
# We need to check and make sure # We need to check and make sure
# that the user has permission to enter a bug against this product. # that the user has permission to enter a bug against this product.
......
...@@ -71,7 +71,6 @@ require "CGI.pl"; ...@@ -71,7 +71,6 @@ require "CGI.pl";
require "globals.pl"; require "globals.pl";
$::lockcount = 0; $::lockcount = 0;
ConnectToDatabase();
GetVersionTable(); GetVersionTable();
......
...@@ -36,11 +36,9 @@ use vars qw( ...@@ -36,11 +36,9 @@ use vars qw(
$vars $vars
); );
# Establish a connection to the database backend.
ConnectToDatabase();
# Check whether or not the user is logged in and, if so, set the $::userid # 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 # Main Body Execution
......
...@@ -33,9 +33,7 @@ use vars qw($userid @legal_keywords); ...@@ -33,9 +33,7 @@ use vars qw($userid @legal_keywords);
# Use global template variables. # Use global template variables.
use vars qw($template $vars); use vars qw($template $vars);
ConnectToDatabase(); Bugzilla->login();
quietly_check_login();
GetVersionTable(); GetVersionTable();
......
...@@ -31,6 +31,7 @@ require "CGI.pl"; ...@@ -31,6 +31,7 @@ require "CGI.pl";
use vars qw($template $userid %COOKIE); use vars qw($template $userid %COOKIE);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::Bug; use Bugzilla::Bug;
use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::BugMail; use Bugzilla::BugMail;
...@@ -43,8 +44,7 @@ unless ( Param("move-enabled") ) { ...@@ -43,8 +44,7 @@ unless ( Param("move-enabled") ) {
exit; exit;
} }
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -38,9 +38,7 @@ require "CGI.pl"; ...@@ -38,9 +38,7 @@ require "CGI.pl";
use vars qw($template $vars); use vars qw($template $vars);
ConnectToDatabase(); Bugzilla->login();
quietly_check_login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -53,8 +53,7 @@ sub sillyness { ...@@ -53,8 +53,7 @@ sub sillyness {
# Use global template variables. # Use global template variables.
use vars qw($vars $template); use vars qw($vars $template);
ConnectToDatabase(); my $user = Bugzilla->login(LOGIN_REQUIRED);
my $user = confirm_login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -55,8 +55,7 @@ use vars qw(%versions ...@@ -55,8 +55,7 @@ use vars qw(%versions
%legal_severity %legal_severity
); );
ConnectToDatabase(); my $user = Bugzilla->login(LOGIN_REQUIRED);
my $user = confirm_login();
my $whoid = $user->id; my $whoid = $user->id;
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -28,6 +28,8 @@ use lib "."; ...@@ -28,6 +28,8 @@ use lib ".";
require "CGI.pl"; require "CGI.pl";
use Bugzilla::Constants;
use vars qw( use vars qw(
@CheckOptionValues @CheckOptionValues
@legal_resolution @legal_resolution
...@@ -49,16 +51,14 @@ use vars qw( ...@@ -49,16 +51,14 @@ use vars qw(
$vars $vars
); );
ConnectToDatabase();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
if (defined $::FORM{"GoAheadAndLogIn"}) { if (defined $::FORM{"GoAheadAndLogIn"}) {
# We got here from a login page, probably from relogin.cgi. We better # We got here from a login page, probably from relogin.cgi. We better
# make sure the password is legit. # make sure the password is legit.
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
} else { } else {
quietly_check_login(); Bugzilla->login();
} }
my $user = Bugzilla->user; my $user = Bugzilla->user;
......
...@@ -28,8 +28,7 @@ use lib qw(.); ...@@ -28,8 +28,7 @@ use lib qw(.);
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase(); Bugzilla->login();
quietly_check_login();
GetVersionTable(); GetVersionTable();
......
...@@ -36,8 +36,9 @@ use lib qw(.); ...@@ -36,8 +36,9 @@ use lib qw(.);
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase(); use Bugzilla::Constants;
confirm_login();
Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -30,11 +30,9 @@ use lib qw(.); ...@@ -30,11 +30,9 @@ use lib qw(.);
require "CGI.pl"; require "CGI.pl";
# We don't want to remove a random logincookie from the db, so # 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 # the logincookie must be correct
Bugzilla->login();
ConnectToDatabase();
quietly_check_login();
Bugzilla->logout(); Bugzilla->logout();
......
...@@ -29,6 +29,7 @@ require "CGI.pl"; ...@@ -29,6 +29,7 @@ require "CGI.pl";
use vars qw($template $vars); use vars qw($template $vars);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants;
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
...@@ -44,11 +45,9 @@ if (grep(/^cmd-/, $cgi->param())) { ...@@ -44,11 +45,9 @@ if (grep(/^cmd-/, $cgi->param())) {
use Bugzilla::Search; use Bugzilla::Search;
ConnectToDatabase();
GetVersionTable(); GetVersionTable();
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
Bugzilla->switch_to_shadow_db(); Bugzilla->switch_to_shadow_db();
......
...@@ -56,8 +56,7 @@ use Bugzilla; ...@@ -56,8 +56,7 @@ use Bugzilla;
# If we're using bug groups for products, we should apply those restrictions # 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. # to viewing reports, as well. Time to check the login in that case.
ConnectToDatabase(); Bugzilla->login();
quietly_check_login();
GetVersionTable(); GetVersionTable();
......
...@@ -31,9 +31,6 @@ use strict; ...@@ -31,9 +31,6 @@ use strict;
use lib qw(.); use lib qw(.);
require "CGI.pl"; require "CGI.pl";
# Establish a connection to the database backend.
ConnectToDatabase();
# Use Bugzilla's Request module which contains utilities for handling requests. # Use Bugzilla's Request module which contains utilities for handling requests.
use Bugzilla::Flag; use Bugzilla::Flag;
use Bugzilla::FlagType; use Bugzilla::FlagType;
...@@ -44,7 +41,7 @@ use Bugzilla::User; ...@@ -44,7 +41,7 @@ use Bugzilla::User;
use vars qw($template $vars @legal_product @legal_components %components); use vars qw($template $vars @legal_product @legal_components %components);
# Make sure the user is logged in. # Make sure the user is logged in.
quietly_check_login(); Bugzilla->login();
################################################################################ ################################################################################
# Main Body Execution # Main Body Execution
......
...@@ -70,9 +70,7 @@ sub BugListLinks { ...@@ -70,9 +70,7 @@ sub BugListLinks {
# Start # Start
########################################################################### ###########################################################################
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -30,14 +30,12 @@ use vars qw ($template $vars); ...@@ -30,14 +30,12 @@ use vars qw ($template $vars);
require "CGI.pl"; require "CGI.pl";
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
ConnectToDatabase();
############################################################################### ###############################################################################
# Begin Data/Security Validation # Begin Data/Security Validation
############################################################################### ###############################################################################
# Check whether or not the user is currently logged in. # 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 # Make sure the bug ID is a positive integer representing an existing
# bug that the user is authorized to access. # bug that the user is authorized to access.
......
...@@ -25,11 +25,10 @@ use strict; ...@@ -25,11 +25,10 @@ use strict;
use lib qw(.); use lib qw(.);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants;
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase();
use vars qw($template $vars $userid); use vars qw($template $vars $userid);
use Bugzilla::Bug; use Bugzilla::Bug;
...@@ -37,9 +36,9 @@ use Bugzilla::Bug; ...@@ -37,9 +36,9 @@ use Bugzilla::Bug;
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
if ($::FORM{'GoAheadAndLogIn'}) { if ($::FORM{'GoAheadAndLogIn'}) {
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
} else { } else {
quietly_check_login(); Bugzilla->login();
} }
# Editable, 'single' HTML bugs are treated slightly specially in a few places # Editable, 'single' HTML bugs are treated slightly specially in a few places
......
...@@ -31,9 +31,7 @@ use Bugzilla::Config qw(:DEFAULT $webdotdir); ...@@ -31,9 +31,7 @@ use Bugzilla::Config qw(:DEFAULT $webdotdir);
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase(); Bugzilla->login();
quietly_check_login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -31,9 +31,7 @@ require "CGI.pl"; ...@@ -31,9 +31,7 @@ require "CGI.pl";
# Use global template variables. # Use global template variables.
use vars qw($template $vars); use vars qw($template $vars);
ConnectToDatabase(); Bugzilla->login();
quietly_check_login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -26,8 +26,7 @@ use vars qw( ...@@ -26,8 +26,7 @@ use vars qw(
$vars $vars
); );
ConnectToDatabase(); Bugzilla->login();
quietly_check_login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -32,14 +32,14 @@ use lib qw(.); ...@@ -32,14 +32,14 @@ use lib qw(.);
use vars qw($template $vars); use vars qw($template $vars);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants;
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
# Include the Bugzilla CGI and general utility library. # Include the Bugzilla CGI and general utility library.
require "CGI.pl"; require "CGI.pl";
# Establish a connection to the database backend. Bugzilla->login(LOGIN_OPTIONAL);
ConnectToDatabase();
quietly_check_login('permit_anonymous');
# Use the "Bugzilla::Token" module that contains functions for doing various # Use the "Bugzilla::Token" module that contains functions for doing various
# token-related tasks. # token-related tasks.
......
...@@ -308,8 +308,7 @@ sub DoSavedSearches() { ...@@ -308,8 +308,7 @@ sub DoSavedSearches() {
# Live code (not subroutine definitions) starts here # Live code (not subroutine definitions) starts here
############################################################################### ###############################################################################
ConnectToDatabase(); Bugzilla->login(LOGIN_REQUIRED);
confirm_login();
GetVersionTable(); GetVersionTable();
......
...@@ -27,14 +27,13 @@ use strict; ...@@ -27,14 +27,13 @@ use strict;
use lib "."; use lib ".";
use Bugzilla; use Bugzilla;
use Bugzilla::Constants;
require "CGI.pl"; require "CGI.pl";
# Use global template variables # Use global template variables
use vars qw($template $vars); use vars qw($template $vars);
ConnectToDatabase();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
# If the action is show_bug, you need a bug_id. # If the action is show_bug, you need a bug_id.
...@@ -51,10 +50,10 @@ my $action = $::FORM{'action'} || ...@@ -51,10 +50,10 @@ my $action = $::FORM{'action'} ||
if ($action eq "show_bug" || if ($action eq "show_bug" ||
($action eq "show_user" && defined($::FORM{'user'}))) ($action eq "show_user" && defined($::FORM{'user'})))
{ {
quietly_check_login(); Bugzilla->login();
} }
else { else {
confirm_login(); Bugzilla->login(LOGIN_REQUIRED);
} }
################################################################################ ################################################################################
......
...@@ -31,8 +31,6 @@ use strict; ...@@ -31,8 +31,6 @@ use strict;
require "globals.pl"; require "globals.pl";
ConnectToDatabase();
SendSQL("select bug_id,short_desc,login_name from bugs,profiles where " . SendSQL("select bug_id,short_desc,login_name from bugs,profiles where " .
"(bug_status = 'NEW' or bug_status = 'REOPENED') and " . "(bug_status = 'NEW' or bug_status = 'REOPENED') and " .
"to_days(now()) - to_days(delta_ts) > " . Param('whinedays') . "to_days(now()) - to_days(delta_ts) > " . Param('whinedays') .
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment