From 9d6205cdb651fe3769ac58f03068dedb68e7689a Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Mon, 19 Nov 2007 02:20:53 +0000 Subject: Bug 399163: Bugzilla/*.pm should use transactions for database interaction - Patch by Emmanuel Seyman r/a=mkanat --- Bugzilla/Token.pm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'Bugzilla/Token.pm') 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); -- cgit v1.2.3-24-g4f1b