summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Token.pm
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-02-18 06:57:26 +0100
committermkanat%kerio.com <>2005-02-18 06:57:26 +0100
commitd3f8bf365e5b93f58497a25e07fde7ce30884f9d (patch)
treeba45ba2aa22039ecd440ca4c5c7fa421eb158456 /Bugzilla/Token.pm
parentf95d1faba79c94bcf3bf936334d6bb10e03c93b2 (diff)
downloadbugzilla-d3f8bf365e5b93f58497a25e07fde7ce30884f9d.tar.gz
bugzilla-d3f8bf365e5b93f58497a25e07fde7ce30884f9d.tar.xz
Bug 280503: Replace "LOCK/UNLOCK TABLES" with Bugzilla::DB function call
Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=mkanat,a=myk
Diffstat (limited to 'Bugzilla/Token.pm')
-rw-r--r--Bugzilla/Token.pm22
1 files changed, 14 insertions, 8 deletions
diff --git a/Bugzilla/Token.pm b/Bugzilla/Token.pm
index 90efe99bd..9caf91ab2 100644
--- a/Bugzilla/Token.pm
+++ b/Bugzilla/Token.pm
@@ -52,13 +52,14 @@ my $maxtokenage = 3;
sub IssueEmailChangeToken {
my ($userid, $old_email, $new_email) = @_;
+ my $dbh = Bugzilla->dbh;
my $token_ts = time();
my $issuedate = time2str("%Y-%m-%d %H:%M", $token_ts);
# Generate a unique token and insert it into the tokens table.
# We have to lock the tokens table before generating the token,
# since the database must be queried for token uniqueness.
- &::SendSQL("LOCK TABLES tokens WRITE");
+ $dbh->bz_lock_tables('tokens WRITE');
my $token = GenerateUniqueToken();
my $quotedtoken = &::SqlQuote($token);
my $quoted_emails = &::SqlQuote($old_email . ":" . $new_email);
@@ -72,7 +73,7 @@ sub IssueEmailChangeToken {
tokentype , eventdata )
VALUES ( $userid , '$issuedate' , $quotedtoken ,
'emailnew' , $quoted_emails )");
- &::SendSQL("UNLOCK TABLES");
+ $dbh->bz_unlock_tables();
# Mail the user the token along with instructions for using it.
@@ -110,6 +111,8 @@ sub IssuePasswordToken {
my ($loginname) = @_;
+ my $dbh = Bugzilla->dbh;
+
# Retrieve the user's ID from the database.
my $quotedloginname = &::SqlQuote($loginname);
&::SendSQL("SELECT profiles.userid, tokens.issuedate FROM profiles
@@ -129,13 +132,13 @@ sub IssuePasswordToken {
# Generate a unique token and insert it into the tokens table.
# We have to lock the tokens table before generating the token,
# since the database must be queried for token uniqueness.
- &::SendSQL("LOCK TABLES tokens WRITE");
+ $dbh->bz_lock_tables('tokens WRITE');
my $token = GenerateUniqueToken();
my $quotedtoken = &::SqlQuote($token);
my $quotedipaddr = &::SqlQuote($::ENV{'REMOTE_ADDR'});
&::SendSQL("INSERT INTO tokens ( userid , issuedate , token , tokentype , eventdata )
VALUES ( $userid , NOW() , $quotedtoken , 'password' , $quotedipaddr )");
- &::SendSQL("UNLOCK TABLES");
+ $dbh->bz_unlock_tables();
# Mail the user the token along with instructions for using it.
@@ -158,10 +161,11 @@ sub IssuePasswordToken {
sub CleanTokenTable {
- &::SendSQL("LOCK TABLES tokens WRITE");
+ my $dbh = Bugzilla->dbh;
+ $dbh->bz_lock_tables('tokens WRITE');
&::SendSQL("DELETE FROM tokens
WHERE TO_DAYS(NOW()) - TO_DAYS(issuedate) >= " . $maxtokenage);
- &::SendSQL("UNLOCK TABLES");
+ $dbh->bz_unlock_tables();
}
@@ -198,6 +202,8 @@ sub Cancel {
my ($token, $cancelaction) = @_;
+ my $dbh = Bugzilla->dbh;
+
# Quote the token for inclusion in SQL statements.
my $quotedtoken = &::SqlQuote($token);
@@ -232,9 +238,9 @@ sub Cancel {
Bugzilla::BugMail::MessageToMTA($message);
# Delete the token from the database.
- &::SendSQL("LOCK TABLES tokens WRITE");
+ $dbh->bz_lock_tables('tokens WRITE');
&::SendSQL("DELETE FROM tokens WHERE token = $quotedtoken");
- &::SendSQL("UNLOCK TABLES");
+ $dbh->bz_unlock_tables();
}
sub DeletePasswordTokens {