summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Token.pm
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2007-11-19 03:20:53 +0100
committerlpsolit%gmail.com <>2007-11-19 03:20:53 +0100
commit9d6205cdb651fe3769ac58f03068dedb68e7689a (patch)
tree47414a6cf3f484e27a74fe91842ebe08843bb2c5 /Bugzilla/Token.pm
parent0dadaed4ffb582ccfbc2356e7715007819d1cea2 (diff)
downloadbugzilla-9d6205cdb651fe3769ac58f03068dedb68e7689a.tar.gz
bugzilla-9d6205cdb651fe3769ac58f03068dedb68e7689a.tar.xz
Bug 399163: Bugzilla/*.pm should use transactions for database interaction - Patch by Emmanuel Seyman <eseyman@linagora.com> r/a=mkanat
Diffstat (limited to 'Bugzilla/Token.pm')
-rw-r--r--Bugzilla/Token.pm8
1 files changed, 2 insertions, 6 deletions
diff --git a/Bugzilla/Token.pm b/Bugzilla/Token.pm
index 7db6b9165..2f911fca1 100644
--- a/Bugzilla/Token.pm
+++ b/Bugzilla/Token.pm
@@ -171,12 +171,10 @@ sub issue_session_token {
sub CleanTokenTable {
my $dbh = Bugzilla->dbh;
- $dbh->bz_lock_tables('tokens WRITE');
$dbh->do('DELETE FROM tokens
WHERE ' . $dbh->sql_to_days('NOW()') . ' - ' .
$dbh->sql_to_days('issuedate') . ' >= ?',
undef, MAX_TOKEN_AGE);
- $dbh->bz_unlock_tables();
}
sub GenerateUniqueToken {
@@ -301,9 +299,7 @@ sub delete_token {
return unless defined $token;
trick_taint($token);
- $dbh->bz_lock_tables('tokens WRITE');
$dbh->do("DELETE FROM tokens WHERE token = ?", undef, $token);
- $dbh->bz_unlock_tables();
}
# Given a token, makes sure it comes from the currently logged in user
@@ -364,14 +360,14 @@ sub _create_token {
trick_taint($tokentype);
trick_taint($eventdata);
- $dbh->bz_lock_tables('tokens WRITE');
+ $dbh->bz_start_transaction();
my $token = GenerateUniqueToken();
$dbh->do("INSERT INTO tokens (userid, issuedate, token, tokentype, eventdata)
VALUES (?, NOW(), ?, ?, ?)", undef, ($userid, $token, $tokentype, $eventdata));
- $dbh->bz_unlock_tables();
+ $dbh->bz_commit_transaction();
if (wantarray) {
my (undef, $token_ts, undef) = GetTokenData($token);